/* ===== Banana Hormuz — retro pixel UI ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #f4e4c1;
  --ink-dim: #c8b48a;
  --panel: rgba(18, 14, 30, 0.92);
  --panel-edge: #4a3b6b;
  --accent: #ffcf4d;
  --accent2: #ff6b4d;
  --good: #7ddc6b;
}

html, body {
  height: 100%;
  background: #0a0712;
  color: var(--ink);
  font-family: "Courier New", Courier, monospace;
  overflow: hidden;
  -webkit-font-smoothing: none;
}

/* Stage keeps the 8:5 aspect ratio of the 800x500 canvas and centers it. */
#stage {
  position: absolute;
  inset: 0;
  margin: auto;
  width: min(100vw, calc(100vh * 1.6));
  height: min(100vh, calc(100vw / 1.6));
  max-width: 100vw;
  max-height: 100vh;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #1a2740;
}

/* ===== Overlays ===== */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  text-align: center;
  background: radial-gradient(ellipse at center, rgba(10,7,18,0.55), rgba(10,7,18,0.88));
  padding: 4%;
}
.overlay.hidden, .hud.hidden { display: none; }

.title {
  font-size: clamp(2rem, 7vw, 4.6rem);
  letter-spacing: 0.12em;
  line-height: 0.9;
  color: var(--accent);
  text-shadow: 4px 4px 0 var(--accent2), 8px 8px 0 rgba(0,0,0,0.5);
}
.title span { display: block; color: var(--ink); text-shadow: 4px 4px 0 #2a6b8a, 8px 8px 0 rgba(0,0,0,0.5); }
.subtitle { color: var(--ink-dim); font-size: clamp(0.8rem, 2vw, 1.1rem); letter-spacing: 0.08em; }
.credit { position: absolute; bottom: 3%; color: var(--ink-dim); font-size: 0.78rem; opacity: 0.85; }
.credit a { color: var(--accent); text-decoration: none; }
.credit a:hover { text-decoration: underline; }

.panel-title {
  font-size: clamp(1.1rem, 3.5vw, 2rem);
  color: var(--accent);
  letter-spacing: 0.1em;
  text-shadow: 3px 3px 0 rgba(0,0,0,0.5);
}

/* ===== Buttons ===== */
.btn-col { display: flex; flex-direction: column; gap: 0.7rem; width: min(360px, 80%); }
.btn {
  font-family: inherit;
  font-size: clamp(0.85rem, 2.2vw, 1.15rem);
  font-weight: bold;
  letter-spacing: 0.08em;
  color: #1a1226;
  background: var(--accent);
  border: 0;
  border-bottom: 4px solid #b8902a;
  padding: 0.7em 1em;
  cursor: pointer;
  transition: transform 0.05s, filter 0.1s;
  text-transform: uppercase;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(3px); border-bottom-width: 1px; }
.btn.ghost { background: transparent; color: var(--ink); border: 2px solid var(--panel-edge); border-bottom-width: 2px; }
.btn.ghost:hover { background: rgba(255,255,255,0.08); }
.btn.back { margin-top: 0.4rem; width: min(220px, 70%); }
.btn.fire {
  background: var(--accent2);
  border-bottom-color: #a83a26;
  color: #fff;
  font-size: clamp(0.9rem, 2.6vw, 1.3rem);
  padding: 0.6em 1.4em;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Character select ===== */
.char-grid { display: flex; gap: 1.2rem; flex-wrap: wrap; justify-content: center; }
.char-card {
  background: var(--panel);
  border: 2px solid var(--panel-edge);
  padding: 1rem 1.2rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: 150px;
  transition: transform 0.08s, border-color 0.1s;
}
.char-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.char-card canvas { image-rendering: pixelated; background: rgba(0,0,0,0.25); }
.char-card .cname { font-weight: bold; color: var(--accent); letter-spacing: 0.05em; }
.char-card .cweapon { font-size: 0.72rem; color: var(--ink-dim); }
.char-card .cweapon-icon { image-rendering: pixelated; background: rgba(0,0,0,0.2); border-radius: 2px; }

/* ===== HUD ===== */
.hud {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: var(--panel);
  border-top: 3px solid var(--panel-edge);
  padding: 0.55rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.hud-info { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; font-size: clamp(0.7rem, 1.8vw, 1rem); }
.turn-label { font-weight: bold; color: var(--accent); letter-spacing: 0.06em; }
.wind { display: flex; align-items: center; gap: 0.4rem; color: var(--ink-dim); }
.wind .lbl { font-size: 0.7em; }
.wind-arrow { font-size: 1.3em; color: var(--good); }
.score-line { font-weight: bold; letter-spacing: 0.1em; }

.hud-controls { display: flex; align-items: flex-end; gap: 0.9rem; flex-wrap: wrap; }
.ctrl { display: flex; flex-direction: column; gap: 0.2rem; flex: 1 1 160px; font-size: clamp(0.7rem, 1.7vw, 0.95rem); letter-spacing: 0.05em; }
.ctrl b { color: var(--accent); }
.ctrl input[type=range] { width: 100%; accent-color: var(--accent2); cursor: pointer; }

/* ===== Banner ===== */
.banner { background: rgba(10,7,18,0.85); }

/* ===== Scores table ===== */
.score-table { border-collapse: collapse; background: var(--panel); border: 2px solid var(--panel-edge); font-size: clamp(0.7rem, 1.8vw, 1rem); min-width: min(560px, 92%); }
.score-table th, .score-table td { padding: 0.45em 0.8em; text-align: left; border-bottom: 1px solid rgba(255,255,255,0.08); }
.score-table th { color: var(--accent); letter-spacing: 0.08em; }
.score-table td:last-child, .score-table th:last-child { text-align: right; color: var(--good); font-weight: bold; }
.score-table tr.empty td { text-align: center; color: var(--ink-dim); }

/* ===== Cheat toast ===== */
.toast {
  position: absolute;
  top: 8%;
  left: 50%;
  transform: translate(-50%, -16px);
  background: rgba(10, 7, 18, 0.92);
  border: 2px solid var(--accent);
  color: var(--accent);
  font-weight: bold;
  letter-spacing: 0.08em;
  padding: 0.6em 1.1em;
  font-size: clamp(0.8rem, 2vw, 1.05rem);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== Help ===== */
.help-text { max-width: min(620px, 92%); text-align: left; display: flex; flex-direction: column; gap: 0.7rem; color: var(--ink); font-size: clamp(0.78rem, 1.9vw, 1rem); line-height: 1.5; }
.help-text b { color: var(--accent); }
.help-text .keys { color: var(--ink-dim); font-size: 0.85em; border-top: 1px solid var(--panel-edge); padding-top: 0.6rem; }

/* =====================================================================
   Responsive — PORTRAIT / MOBILE
   Stop letterboxing the 8:5 stage into a short strip. Instead fill the
   screen: canvas at top (full width, keeps ratio), HUD flows BELOW it
   (no longer overlapping the playfield), and menus get the full height
   so the footer can't sit behind the buttons.
   ===================================================================== */
@media (orientation: portrait) {
  #stage {
    position: relative;
    inset: auto;
    margin: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    max-height: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  #game {
    width: 100vw;
    height: calc(100vw / 1.6);   /* keep the 8:5 ratio, full width */
    flex: 0 0 auto;
  }
  /* HUD sits below the canvas and sizes to its content */
  .hud {
    position: static;
    flex: 0 0 auto;
    gap: 0.6rem;
    padding-bottom: max(0.55rem, env(safe-area-inset-bottom));
  }
  .hud-controls { gap: 0.7rem; }
  .btn.fire { width: 100%; }                 /* big, easy-to-tap fire button */
  .ctrl input[type=range] { height: 1.8rem; } /* larger touch target */
  .ctrl { flex: 1 1 45%; }
}

/* =====================================================================
   Responsive — SHORT VIEWPORTS (landscape phones)
   Keep the centered layout, but compact the menu + HUD so the footer
   credit never collides with the buttons and the HUD stays slim.
   ===================================================================== */
@media (max-height: 520px) {
  .overlay { gap: 0.5rem; padding: 2% 4%; }
  .title { font-size: clamp(1.4rem, 6vh, 2.6rem); }
  .btn-col { gap: 0.45rem; }
  .btn { padding: 0.45em 1em; }
  .btn.back { margin-top: 0.2rem; }
  .credit { font-size: 0.68rem; bottom: 1.5%; }
  .hud { padding: 0.35rem 0.7rem; gap: 0.3rem; }
  .hud-info { font-size: 0.72rem; }
}
