/* ===== Merlion Defense stylesheet — light pixel-arcade theme ===== */
* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; -webkit-user-select: none; }

:root {
  --gold: #f6c945;
  --red: #d94f3d;
  --teal: #1e6f5c;
  --ink: #2b2118;            /* warm dark ink for text + pixel borders */
  --paper: #fdf6e3;          /* warm paper panel */
  --paper-2: #f6ead2;
  --line: #d8c9a8;
}

html, body { height: 100%; }
body {
  background: #9fdcf2;
  font-family: "Courier New", "Lucida Console", monospace;
  color: var(--ink);
  overflow: hidden;
}

/* animated pixel Singapore backdrop (menus only; game screen covers it) */
#menu-bg {
  position: fixed; inset: 0; z-index: 0;
  width: 100vw; height: 100vh;
  image-rendering: pixelated;
}

.screen { display: none; width: 100vw; height: 100vh; align-items: center; justify-content: center; position: relative; z-index: 1; }
.screen.active { display: flex; }
.hidden { display: none !important; }

/* pixel icon inside buttons */
.btn-pix {
  width: 22px; height: 22px; image-rendering: pixelated; object-fit: contain;
  margin-right: 10px; vertical-align: -4px; flex-shrink: 0;
}
.small-btn .btn-pix, .hud-btn .btn-pix { width: 17px; height: 17px; margin-right: 6px; vertical-align: -3px; }
.hud-btn .btn-pix { margin-right: 0; }

/* ===== Menu ===== */
.menu-box {
  text-align: center; animation: fadein .5s;
  background: rgba(253, 246, 227, .92);
  border: 4px solid var(--ink); border-radius: 4px;
  box-shadow: 0 0 0 4px #fff, 8px 10px 0 rgba(43,33,24,.28);
  padding: 18px 32px 16px;
  image-rendering: pixelated;
}
.title-merlion { font-size: 62px; filter: drop-shadow(0 6px 0 rgba(43,33,24,.25)); }
.pixel-merlion { width: 84px; height: auto; image-rendering: pixelated; }
.menu-box h1 {
  font-size: 42px; line-height: .95; letter-spacing: 2px; font-weight: bold;
  color: var(--red);
  text-shadow: 2px 2px 0 var(--gold), 4px 4px 0 rgba(43,33,24,.2);
  margin: 6px 0 4px;
}
.tagline { color: #6b5d4a; margin-bottom: 14px; font-style: italic; max-width: 400px; font-size: 13px; margin-left:auto; margin-right:auto; }
.credits { margin-top: 14px; color: #8d7c62; font-size: 11px; }

/* chunky pixel buttons: hard borders, stepped drop shadow, no rounding */
.big-btn {
  display: flex; align-items: center; justify-content: center;
  margin: 8px auto; padding: 9px 30px; min-width: 230px;
  font-family: inherit; font-size: 16px; font-weight: bold; letter-spacing: 1px;
  color: #3a2500; background: var(--gold);
  border: 3px solid var(--ink); border-radius: 0; cursor: pointer;
  box-shadow: inset 0 -6px 0 #d9a01f, inset 0 4px 0 #ffe08a, 4px 4px 0 rgba(43,33,24,.55);
  transition: transform .06s;
  image-rendering: pixelated;
}
.big-btn:hover { transform: translate(-1px,-1px); box-shadow: inset 0 -6px 0 #d9a01f, inset 0 4px 0 #ffe08a, 5px 5px 0 rgba(43,33,24,.55); }
.big-btn:active { transform: translate(3px,3px); box-shadow: inset 0 -6px 0 #d9a01f, inset 0 4px 0 #ffe08a, 1px 1px 0 rgba(43,33,24,.55); }
.big-btn.secondary {
  color: #fdf6e3; background: #3f8a8c;
  box-shadow: inset 0 -6px 0 #2d686a, inset 0 4px 0 #63b0b2, 4px 4px 0 rgba(43,33,24,.55);
}
.big-btn.secondary:hover { box-shadow: inset 0 -6px 0 #2d686a, inset 0 4px 0 #63b0b2, 5px 5px 0 rgba(43,33,24,.55); }
.big-btn.secondary:active { box-shadow: inset 0 -6px 0 #2d686a, inset 0 4px 0 #63b0b2, 1px 1px 0 rgba(43,33,24,.55); }

.small-btn {
  display: inline-flex; align-items: center;
  padding: 8px 16px; font-family: inherit; font-size: 14px; font-weight: bold;
  color: var(--ink); background: var(--paper);
  border: 3px solid var(--ink); border-radius: 0; cursor: pointer;
  box-shadow: 3px 3px 0 rgba(43,33,24,.5);
  transition: transform .06s;
}
.small-btn:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 rgba(43,33,24,.5); }
.small-btn:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 rgba(43,33,24,.5); }

.save-row { display: flex; gap: 10px; justify-content: center; margin-top: 10px; }
.save-row .small-btn { padding: 6px 12px; font-size: 12px; }

/* ===== Armory ===== */
#screen-armory { flex-direction: column; padding: 24px; }
.armory-grid {
  width: 100%; max-width: 860px; flex: 1; overflow-y: auto;
  display: grid; grid-template-columns: 1fr; gap: 10px; padding: 6px 6px 30px;
}
.armory-card {
  display: flex; align-items: center; gap: 16px;
  background: rgba(253, 246, 227, .94);
  border: 3px solid var(--ink); border-radius: 0; padding: 10px 16px;
  cursor: pointer; transition: transform .08s;
  box-shadow: 4px 4px 0 rgba(43,33,24,.35);
}
.armory-card:hover { transform: translate(-1px,-2px); box-shadow: 5px 6px 0 rgba(43,33,24,.35); }
.armory-card.buyable { border-color: #b8860b; box-shadow: 4px 4px 0 rgba(184,134,11,.5); }
.armory-card.owned { border-color: #2e7d32; }
.armory-card.equipped { background: #e2f2df; }
.armory-card.locked { opacity: .55; filter: grayscale(.5); cursor: not-allowed; }
.armory-card .ac-ico { width: 52px; height: 52px; image-rendering: pixelated; object-fit: contain; flex-shrink: 0; }
.armory-card .ac-body { flex: 1; }
.armory-card .ac-name { font-size: 17px; font-weight: bold; color: var(--ink); }
.armory-card .ac-kind { font-size: 11px; color: #8d7c62; font-weight: normal; margin-left: 8px; }
.armory-card .ac-desc { font-size: 12px; color: #6b5d4a; margin-top: 2px; }
.armory-card .ac-stats { font-size: 12px; color: #a4681c; margin-top: 2px; }
.armory-card .ac-cost { font-size: 15px; font-weight: bold; color: #b8860b; white-space: nowrap; }
.armory-card.owned .ac-cost { color: #2e7d32; }

.levels-header-right { display: flex; align-items: center; gap: 12px; }

/* ===== Help ===== */
.help-box {
  max-width: 860px; max-height: 92vh; overflow-y: auto;
  background: rgba(253, 246, 227, .95);
  border: 4px solid var(--ink); border-radius: 4px;
  padding: 30px 36px;
  box-shadow: 0 0 0 4px #fff, 8px 10px 0 rgba(43,33,24,.28);
}
.help-box h2 { color: var(--red); margin-bottom: 14px; font-size: 32px; text-shadow: 2px 2px 0 var(--gold); }
.help-box h3 { color: #a4681c; margin: 14px 0 4px; }
.help-box p { color: #4a3f30; line-height: 1.45; font-size: 15px; margin-bottom: 6px; }
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; margin-bottom: 18px; }
@media (max-width: 760px) { .help-cols { grid-template-columns: 1fr; } }

/* ===== Level select ===== */
#screen-levels { flex-direction: column; padding: 24px; }
.levels-header {
  width: 100%; max-width: 1060px; display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 18px;
  background: rgba(253, 246, 227, .92);
  border: 3px solid var(--ink); padding: 10px 16px;
  box-shadow: 4px 4px 0 rgba(43,33,24,.35);
}
.levels-header h2 { color: var(--red); font-size: 26px; text-shadow: 2px 2px 0 var(--gold); }
.total-stars { font-size: 19px; color: #b8860b; font-weight: bold; }

.level-grid {
  width: 100%; max-width: 1060px; flex: 1; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px; padding: 6px 6px 30px;
}
.act-header {
  grid-column: 1 / -1;
  display: flex; align-items: baseline; gap: 12px;
  padding: 8px 10px 6px; margin-top: 6px;
  background: rgba(43,33,24,.82); border: 3px solid var(--ink);
  box-shadow: 3px 3px 0 rgba(43,33,24,.3);
}
.act-header .act-name { color: var(--gold); font-weight: bold; font-size: 17px; letter-spacing: 1px; }
.act-header .act-blurb { color: #d8cdb0; font-size: 13px; font-style: italic; }

.level-card {
  background: rgba(253, 246, 227, .94);
  border: 3px solid var(--ink); border-radius: 0; padding: 12px 14px;
  cursor: pointer; position: relative; transition: transform .08s;
  box-shadow: 4px 4px 0 rgba(43,33,24,.35);
}
.level-card:hover { transform: translate(-1px,-3px); border-color: #b8860b; box-shadow: 5px 7px 0 rgba(43,33,24,.35); }
.level-card.locked { opacity: .5; cursor: not-allowed; filter: grayscale(.7); }
.level-card .lv-num { font-size: 12px; color: #8d7c62; letter-spacing: 1px; }
.level-card .lv-name { font-size: 16px; font-weight: bold; color: var(--ink); margin: 2px 0 6px; }
.level-card .lv-stars { color: #e0a010; font-size: 18px; letter-spacing: 2px; }
.level-card .lv-diff { position: absolute; top: 10px; right: 12px; font-size: 11px; padding: 2px 8px; border: 2px solid var(--ink); font-weight: bold; color: #fff; }
.level-card .lv-badge {
  width: 16px; height: 16px; margin-left: 5px; vertical-align: -2px;
  image-rendering: pixelated; opacity: .32; filter: grayscale(1);
}
.level-card .lv-badge.done { opacity: 1; filter: none; }
.level-card .lv-tod { font-weight: normal; opacity: .85; font-size: 9px; margin-left: 4px; }
.diff-easy   { background: #2e7d32; }
.diff-normal { background: #ef6c00; }
.diff-hard   { background: #c62828; }
.diff-heroic { background: #6a1b9a; }

/* ===== Mode picker (Campaign / Heroic / Iron) ===== */
#mode-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(43,33,24,.55); display: flex; align-items: center; justify-content: center;
}
.mode-box { max-width: 560px; width: 92vw; text-align: left; }
.mode-box h2 { text-align: center; }
.mode-sub { text-align: center; color: #8d7c62; margin-bottom: 16px; }
.mode-btn {
  display: flex; align-items: center; gap: 14px; width: 100%;
  margin: 10px 0; padding: 12px 16px; cursor: pointer; text-align: left;
  background: var(--paper-2);
  border: 3px solid var(--ink); border-radius: 0; color: var(--ink);
  font-family: inherit; transition: transform .08s;
  box-shadow: 4px 4px 0 rgba(43,33,24,.4);
}
.mode-btn:hover { border-color: #b8860b; transform: translate(-1px,-2px); box-shadow: 5px 6px 0 rgba(43,33,24,.4); }
.mode-btn .mode-ico { width: 34px; height: 34px; image-rendering: pixelated; object-fit: contain; }
.mode-btn .mode-body { flex: 1; }
.mode-btn .mode-name { display: block; font-size: 18px; font-weight: bold; }
.mode-btn .mode-desc { display: block; font-size: 12px; color: #6b5d4a; margin-top: 2px; }
.mode-btn .mode-extra { font-size: 11px; color: #a4681c; margin-top: 3px; }
.mode-btn .mode-done { font-size: 13px; color: #b8860b; white-space: nowrap; }
.mode-btn.mode-heroic .mode-ico { filter: drop-shadow(0 0 6px rgba(255,90,40,.7)); }
.mode-btn.mode-iron .mode-ico { filter: drop-shadow(0 0 6px rgba(120,140,170,.8)); }
.mode-box .big-btn { margin-top: 14px; }

/* ===== Game screen (stays dark — it's the battlefield) ===== */
#screen-game { background: #101820; }
#game-wrap { position: relative; }
#game-canvas {
  display: block; background: #274e13;
  border: 4px solid #0d1720; border-radius: 8px;
  box-shadow: 0 18px 50px rgba(0,0,0,.6);
  max-width: calc(100vw - 16px); max-height: calc(100vh - 16px);
  image-rendering: pixelated;
}

#hud {
  position: absolute; top: 10px; left: 12px; right: 12px;
  display: flex; justify-content: space-between; pointer-events: none;
}
.hud-left, .hud-right { display: flex; gap: 8px; pointer-events: auto; }
.hud-item {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(253,246,227,.92); border: 3px solid var(--ink); border-radius: 0;
  padding: 5px 12px; font-size: 16px; font-weight: bold; color: var(--ink);
  box-shadow: 2px 2px 0 rgba(43,33,24,.5);
}
.hud-item .hud-pix { width: 17px; height: 17px; image-rendering: pixelated; }
.hud-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(253,246,227,.92); border: 3px solid var(--ink); border-radius: 0;
  padding: 5px 10px; font-family: inherit; font-size: 15px; font-weight: bold;
  color: var(--ink); cursor: pointer; min-width: 42px;
  box-shadow: 2px 2px 0 rgba(43,33,24,.5);
}
.hud-btn:hover { transform: translate(-1px,-1px); box-shadow: 3px 3px 0 rgba(43,33,24,.5); }
.hud-btn:active { transform: translate(1px,1px); box-shadow: 1px 1px 0 rgba(43,33,24,.5); }

#btn-next-wave {
  position: absolute; bottom: 14px; right: 14px;
  display: flex; align-items: center;
  padding: 11px 20px; font-family: inherit; font-size: 16px; font-weight: bold; color: #3a2500;
  background: var(--gold);
  border: 3px solid var(--ink); border-radius: 0; cursor: pointer;
  box-shadow: inset 0 -5px 0 #d9a01f, inset 0 3px 0 #ffe08a, 4px 4px 0 rgba(43,33,24,.55);
  animation: pulse 1.4s infinite;
}
#btn-next-wave:disabled { animation: none; opacity: .35; cursor: default; }
#btn-next-wave #next-wave-timer { margin-left: 6px; }
@keyframes pulse { 0%,100% { transform: scale(1);} 50% { transform: scale(1.05);} }

/* ===== Popups (in-game, stay dark for contrast on the map) ===== */
.popup {
  position: absolute; z-index: 20;
  background: rgba(253,246,227,.97); border: 3px solid var(--ink); border-radius: 0;
  padding: 10px; box-shadow: 5px 5px 0 rgba(43,33,24,.45);
  display: flex; gap: 8px;
  flex-wrap: wrap; max-width: 388px; justify-content: center;
}
.popup .p-btn {
  width: 84px; padding: 8px 4px; text-align: center; cursor: pointer;
  background: var(--paper-2); border: 2px solid var(--ink); border-radius: 0;
  color: var(--ink); font-family: inherit;
  box-shadow: 2px 2px 0 rgba(43,33,24,.4);
}
.popup .p-btn:hover { border-color: #b8860b; background: #fff3d0; }
.popup .p-btn:active { transform: translate(1px,1px); box-shadow: 1px 1px 0 rgba(43,33,24,.4); }
.popup .p-btn.disabled { opacity: .4; cursor: default; }
.popup .p-btn.ult {
  border-color: #b8860b; background: #fff3d0; width: 110px;
  box-shadow: 2px 2px 0 rgba(184,134,11,.55), 0 0 10px rgba(246,201,69,.45);
}
.popup .p-btn.ult .nm { color: #8a5a00; }
.popup .p-btn .ico { font-size: 26px; display: block; }
.popup .p-btn img.ico { width: 42px; height: 39px; margin: 0 auto; image-rendering: pixelated; object-fit: contain; }
.popup .p-btn .nm { font-size: 10px; display: block; margin: 3px 0 2px; color: #4a3f30; font-weight: bold; }
.popup .p-btn .cost { font-size: 12px; font-weight: bold; color: #b8860b; display: block; }
.popup .p-btn.sell .cost { color: var(--red); }

/* ===== Banner ===== */
#banner {
  position: absolute; top: 42%; left: 50%; transform: translate(-50%,-50%);
  font-size: 42px; font-weight: bold; color: var(--gold);
  text-shadow: 3px 3px 0 var(--ink), 0 8px 22px rgba(0,0,0,.8);
  pointer-events: none; z-index: 30; white-space: nowrap;
  animation: bannerpop 2.2s forwards;
}
@keyframes bannerpop {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(.4); }
  15% { opacity: 1; transform: translate(-50%,-50%) scale(1.08); }
  25% { transform: translate(-50%,-50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%,-70%) scale(1); }
}

/* ===== Overlays ===== */
#end-overlay, #pause-overlay {
  position: absolute; inset: 0; z-index: 40;
  background: rgba(43,33,24,.55); display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
}
.end-box {
  background: var(--paper); border: 4px solid var(--ink); border-radius: 4px;
  padding: 34px 46px; text-align: center;
  box-shadow: 0 0 0 4px #fff, 8px 10px 0 rgba(43,33,24,.35);
  animation: fadein .3s;
}
.end-box h2 { font-size: 38px; color: var(--red); text-shadow: 2px 2px 0 var(--gold); margin-bottom: 10px; }
.end-stars { font-size: 44px; letter-spacing: 8px; color: #e0a010; margin-bottom: 8px; }
.end-stars .off { color: #d8cdb0; }
#end-msg { color: #4a3f30; margin-bottom: 18px; }
.end-btns .big-btn { min-width: 240px; }

@keyframes fadein { from { opacity: 0; transform: scale(.94);} to { opacity: 1; transform: scale(1);} }
