/* ===========================================================================
   SuperInno — ASCII platformer styles.
   Dark "terminal" theme with per-tilE colour classes driven from game.js.
   ===========================================================================*/
:root {
  --bg:        #0b0e13;
  --bg2:       #11151c;
  --panel:     #161b24;
  --panel2:    #1b212c;
  --line:      #2a3342;
  --text:      #d7dfeb;
  --dim:       #8892a4;
  --accent:    #4fd1c5;

  /* tile palette */
  --c-ground:  #8b6f47;
  --c-brick:   #a95f34;
  --c-q:       #e8b23a;
  --c-pipe:    #3fa66a;
  --c-lava:    #ff4d2e;
  --c-flag:    #6fdcff;
  --c-cloud:   #607089;
  --c-coin:    #ffd23f;
  --c-player:  #7cfc8e;
  --c-bugsy:   #ff7a5c;
  --c-shellox: #ffb15c;
  --c-shell:   #ffd87a;
  --c-boss:    #ff5470;
  --c-dead:    #ff4d4d;

  --mono: "Courier New", "DejaVu Sans Mono", Consolas, Menlo, monospace;
}

/* ---------- reset ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: radial-gradient(1200px 700px at 50% 12%, #141a24 0%, var(--bg) 60%);
  color: var(--text);
  font-family: var(--mono);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  user-select: none; -webkit-user-select: none;
}

/* ---------- shell layout ---------- */
#app {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  padding: max(4px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right))
           max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
  gap: 6px;
}

/* ---------- HUD ---------- */
#hud {
  flex: 0 0 auto;
  text-align: center;
  font-size: clamp(11px, 2.2vw, 18px);
  letter-spacing: .06em;
  color: var(--dim);
  padding: 4px 8px;
  background: linear-gradient(var(--panel), var(--bg2));
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 1.5em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 0 6px rgba(0,0,0,.6);
}
#hud:empty { visibility: hidden; }

/* ---------- playfield ---------- */
#stageWrap {
  position: relative; flex: 1 1 auto; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  background:
    linear-gradient(rgba(255,255,255,.014) 1px, transparent 1px) 0 0 / 100% 1.25em,
    var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(0,0,0,.55), 0 8px 30px rgba(0,0,0,.4);
}
#stageWrap::after { /* subtle scanline glow */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.14) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply; opacity: .5;
}
#stage {
  font-family: var(--mono);
  font-weight: bold;
  line-height: 1.25;
  white-space: pre;
  color: var(--text);
  text-shadow: 0 0 5px rgba(0,0,0,.8);
  transform-origin: center center;
}
#stage .ln { min-height: 1.25em; }

/* tile + entity colour classes (set by game.js) */
.tg  { color: var(--c-ground); }
.tB  { color: var(--c-brick); }
.tQ  { color: var(--c-q); text-shadow: 0 0 6px rgba(232,178,58,.55); }
.tP  { color: var(--c-pipe); }
.tL  { color: var(--c-lava); text-shadow: 0 0 8px rgba(255,77,46,.7); animation: lava .9s steps(2) infinite; }
.tF  { color: var(--c-flag); text-shadow: 0 0 8px rgba(111,220,255,.7); animation: flag 1.2s ease-in-out infinite; }
.tC  { color: var(--c-cloud); opacity: .8; }
.tO  { color: var(--c-coin); text-shadow: 0 0 7px rgba(255,210,63,.7); animation: coin .8s steps(2) infinite; }

.ePlayer { color: var(--c-player); text-shadow: 0 0 8px rgba(124,252,142,.7); }
.eBug    { color: var(--c-bugsy); }
.eShellK { color: var(--c-shellox); }
.eShell  { color: var(--c-shell); text-shadow: 0 0 7px rgba(255,216,122,.6); }
.eBoss   { color: var(--c-boss); text-shadow: 0 0 10px rgba(255,84,112,.8); }
.eBossFlash { color: #fff; text-shadow: 0 0 12px #fff; }
.eDead   { color: var(--c-dead); }

@keyframes lava  { 0% { opacity: .85; } 50% { opacity: 1; } 100% { opacity: .85; } }
@keyframes coin  { 0% { opacity: .7; } 50% { opacity: 1; } 100% { opacity: .7; } }
@keyframes flag  { 0%,100% { transform: none; } 50% { text-shadow: 0 0 14px rgba(111,220,255,1); } }

/* ---------- rotate hint (portrait phones) ---------- */
#rotateHint {
  display: none;
  position: absolute; inset: 0; z-index: 5;
  flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: rgba(8,10,14,.9);
  font-size: clamp(18px, 6vw, 28px);
  letter-spacing: .1em; color: var(--accent);
  text-shadow: 0 0 10px rgba(79,209,197,.6);
}
#rotateHint::before {
  content: "⟳"; font-size: clamp(40px, 12vw, 64px);
  animation: spin 1.8s linear infinite;
}
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@media (orientation: portrait) and (pointer: coarse) and (max-width: 640px) {
  #rotateHint { display: flex; }
  #touch { display: none !important; }
}

/* ---------- overlays ---------- */
#overlay {
  position: absolute; inset: 0; z-index: 6;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(1000px 600px at 50% 40%, rgba(20,26,36,.86), rgba(6,8,12,.94));
  padding: 16px; text-align: center;
  animation: fade .22s ease-out;
}
#overlay.hidden { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.logo {
  font-family: var(--mono);
  font-weight: bold;
  color: var(--accent);
  font-size: clamp(7px, 2vw, 15px);
  line-height: 1.05;
  white-space: pre;
  text-shadow: 0 0 10px rgba(79,209,197,.5);
  margin-bottom: 6px;
}
.ovTitle { font-size: clamp(24px, 7vw, 52px); letter-spacing: .12em; color: #fff; text-shadow: 0 0 14px rgba(255,255,255,.3); }
.overTitle { color: var(--c-dead); text-shadow: 0 0 16px rgba(255,77,77,.6); }
.ovSub { color: var(--dim); margin-top: 10px; line-height: 1.6; font-size: clamp(12px, 3vw, 16px); }
.ovBody { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 18px; }
.lbl { color: var(--dim); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; margin: 4px 0 8px; width: 100%; max-width: 92vw; }
.sep { width: min(320px, 84vw); border: 0; border-top: 1px dashed var(--line); opacity: .7; margin: 12px 0; }
#lvlSelect { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: min(340px, 88vw); }

button {
  font-family: var(--mono); font-weight: bold;
  cursor: pointer; color: var(--text);
  background: linear-gradient(var(--panel2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 16px; font-size: clamp(13px, 3.4vw, 17px);
  transition: transform .06s ease, background .12s ease, box-shadow .12s ease;
  touch-action: manipulation;
}
button:active { transform: translateY(1px) scale(.99); }
button.primary {
  color: #04121a;
  background: linear-gradient(var(--accent), #33b9ad);
  border-color: #2f9a90;
  box-shadow: 0 4px 14px rgba(79,209,197,.25);
  letter-spacing: .06em;
}
button.lvl { text-align: left; }
button.lvl.locked { opacity: .45; cursor: default; }

button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- mute button ---------- */
#muteBtn {
  position: absolute; top: 8px; right: 10px; z-index: 7;
  padding: 6px 10px; font-size: 12px; background: rgba(20,26,36,.7);
  border-color: var(--line); backdrop-filter: blur(2px);
}
#app[data-phase="MENU"] #muteBtn { top: 12px; }

/* ---------- mobile touch controls ---------- */
#touch {
  position: absolute; inset: auto 0 0 0; z-index: 7;
  display: none;
  padding: 0 12px max(10px, env(safe-area-inset-bottom)) 12px;
  justify-content: space-between; align-items: flex-end;
  pointer-events: none;
}
#touch .pad, #touch .act { pointer-events: auto; }
#touch .pad { display: flex; gap: 10px; align-items: flex-end; }
#touch button {
  width: 60px; height: 60px; min-width: 60px; min-height: 60px;
  font-size: 26px; border-radius: 50%;
  background: rgba(22,28,38,.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(120,140,170,.4);
  color: #cfe;
  touch-action: none;
}
#touch button#t-down { width: 52px; height: 52px; min-width: 52px; min-height: 52px; font-size: 20px; }
#touch .act { display: flex; }
#touch .act #t-jump {
  width: 84px; height: 84px; min-width: 84px; min-height: 84px;
  font-size: 34px;
  background: rgba(79,209,197,.25);
  border-color: rgba(79,209,197,.6);
  color: var(--accent);
  box-shadow: 0 0 16px rgba(79,209,197,.25);
}
@media (pointer: coarse) {
  #touch { display: flex; }
}

/* ---------- small screens: give HUD room ---------- */
@media (max-width: 520px) and (orientation: landscape) {
  #hud { font-size: 11px; }
  #stageWrap { border-radius: 8px; }
}

/* keyboard hint pill (desktop only) */
#keyHint {
  display: none;
  flex: 0 0 auto;
  justify-content: center; gap: 8px;
  color: var(--dim); font-size: 11px;
}
#keyHint kbd {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 6px; font-family: var(--mono); font-size: 11px;
}
@media (hover: hover) and (pointer: fine) {
  #keyHint { display: flex; }
}
