/* Raid Over Moscow II — UI shell. Palette: deep navy/slate, amber accent, teal status. */
:root {
  --bg: #070b12;
  --panel: rgba(12, 19, 31, 0.94);
  --panel-2: #121c2b;
  --line: #24324a;
  --text: #e8eef4;
  --muted: #8fa3b8;
  --amber: #e0a526;
  --amber-2: #f2c05a;
  --teal: #2fbf9b;
  --red: #ff6b5a;
  --steel: #5fb4ff;
  --ui-scale: 1;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: Inter, "Segoe UI", system-ui, sans-serif; overflow: hidden; }
body { background: radial-gradient(ellipse at 50% 30%, #101a2b 0%, #070b12 70%); }
#stage-shell { position: fixed; inset: 0; display: grid; place-items: center; }
#wrap { position: relative; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); border-radius: 4px; overflow: hidden; }
canvas#game { display: block; width: 100%; height: 100%; background: #0b1220; image-rendering: auto; }

/* ---------- modals ---------- */
.modal {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(7, 11, 18, 0.35) 0%, rgba(7, 11, 18, 0.78) 100%);
  backdrop-filter: blur(1.5px);
  padding: 16px;
  z-index: 10;
}
.modal.open { display: flex; animation: fadeIn 0.25s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: calc(24px * var(--ui-scale)) calc(28px * var(--ui-scale));
  width: min(calc(520px * var(--ui-scale)), 100%); max-height: 100%; overflow: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  animation: rise 0.3s ease-out;
  font-size: calc(14px * var(--ui-scale));
}
.card.narrow { width: min(calc(400px * var(--ui-scale)), 100%); }
.card.wide { width: min(calc(820px * var(--ui-scale)), 100%); }
.card h2 { margin: 0 0 6px; font-family: "Black Ops One", "Rajdhani", sans-serif; font-weight: 400; font-size: 1.9em; letter-spacing: 0.02em; }
.card h2 small { font-family: Rajdhani, sans-serif; font-size: 0.45em; color: var(--muted); letter-spacing: 0.12em; text-transform: uppercase; margin-left: 8px; }
.card h3 { font-family: Rajdhani, sans-serif; text-transform: uppercase; letter-spacing: 0.12em; color: var(--amber); font-size: 0.95em; margin: 4px 0 10px; }
.kicker { font-family: Rajdhani, sans-serif; font-weight: 700; letter-spacing: 0.22em; color: var(--amber); font-size: 0.82em; }
.muted { color: var(--muted); }
.sub { color: var(--muted); font-family: Rajdhani, sans-serif; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 10px; }

.btn {
  font-family: Rajdhani, sans-serif; font-weight: 700; font-size: 1.08em; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px;
  padding: 0.62em 1.2em; cursor: pointer; transition: background 0.15s, border-color 0.15s, transform 0.08s;
}
.btn:hover, .btn:focus-visible { border-color: var(--amber); background: #172338; outline: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, var(--amber-2), var(--amber)); color: #1a1204; border-color: #b78418; }
.btn.primary:hover, .btn.primary:focus-visible { background: linear-gradient(180deg, #ffd27a, #e9b034); box-shadow: 0 0 0 3px rgba(224, 165, 38, 0.25); }
.btn.ghost { background: transparent; }
.btn.small { font-size: 0.85em; padding: 0.5em 0.9em; }
.menu { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ---------- title ---------- */
.title-modal { background: linear-gradient(90deg, rgba(7, 11, 18, 0.92) 0%, rgba(7, 11, 18, 0.55) 48%, rgba(7, 11, 18, 0) 75%); justify-content: flex-start; }
.title-card { width: min(calc(440px * var(--ui-scale)), 100%); padding-left: calc(28px * var(--ui-scale)); animation: rise 0.4s ease-out; font-size: calc(14px * var(--ui-scale)); }
#logo { font-family: "Black Ops One", sans-serif; font-weight: 400; font-size: 3.5em; line-height: 0.95; margin: 10px 0 8px; color: #f4f6f8; text-shadow: 0 3px 0 #000, 0 0 30px rgba(224, 165, 38, 0.25); }
#logo span { color: var(--amber); }
.tag { color: #c7d3df; margin: 0 0 8px; font-size: 1.05em; }
.title-card .menu { max-width: calc(280px * var(--ui-scale)); }
.title-card .menu .btn { text-align: left; }
.settings { display: flex; align-items: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg-btn { font-family: Rajdhani, sans-serif; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; background: var(--panel-2); color: var(--muted); border: 0; padding: 0.5em 0.9em; cursor: pointer; font-size: 0.85em; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn.active { background: #1d2c44; color: var(--amber-2); }
.seg-btn:hover { color: var(--text); }
.hiscore { margin-top: 18px; color: var(--muted); font-family: Rajdhani, sans-serif; letter-spacing: 0.1em; text-transform: uppercase; font-size: 0.9em; }
.hiscore b { color: var(--text); font-size: 1.25em; margin-left: 6px; }

.mode-modal { background: radial-gradient(ellipse at center, rgba(7, 11, 18, 0.55) 0%, rgba(7, 11, 18, 0.9) 100%); }
.mode-wrap { width: min(calc(860px * var(--ui-scale)), 100%); text-align: center; font-size: calc(14px * var(--ui-scale)); animation: rise 0.4s ease-out; }
.mode-logo { font-family: "Black Ops One", sans-serif; font-weight: 400; font-size: 3em; margin: 8px 0 4px; color: #f4f6f8; text-shadow: 0 3px 0 #000; }
.mode-logo span { color: var(--amber); }
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: calc(16px * var(--ui-scale)); margin-top: 18px; }
.mode-card { display: flex; flex-direction: column; align-items: stretch; text-align: left; gap: 6px; padding: 10px 10px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; color: var(--text); cursor: pointer; font: inherit; transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s; }
.mode-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; border: 1px solid #1a2536; background: #0b1220; }
.mode-card:hover, .mode-card:focus-visible { border-color: var(--amber); transform: translateY(-2px); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); outline: none; }
.mode-card.classic:hover, .mode-card.classic:focus-visible { border-color: var(--steel); }
.mode-name { font-family: Rajdhani, sans-serif; font-weight: 700; font-size: 1.35em; letter-spacing: 0.06em; text-transform: uppercase; padding: 0 4px; }
.mode-card.classic .mode-name { font-family: "Press Start 2P", monospace; font-size: 0.8em; line-height: 1.6; color: var(--steel); text-transform: none; }
.mode-desc { color: var(--muted); padding: 0 4px; line-height: 1.4; }

/* ---------- briefing ---------- */
.brief p { color: #c7d3df; line-height: 1.5; }
.steps { list-style: none; padding: 0; margin: 14px 0; display: flex; gap: 6px; flex-wrap: wrap; }
.steps li { font-family: Rajdhani, sans-serif; font-weight: 600; font-size: 0.92em; color: var(--muted); border: 1px solid var(--line); border-radius: 20px; padding: 4px 10px 4px 4px; display: flex; align-items: center; gap: 6px; }
.steps li span { width: 20px; height: 20px; border-radius: 50%; background: #1b2638; display: grid; place-items: center; font-size: 0.85em; }
.steps li.now { color: var(--text); border-color: var(--amber); }
.steps li.now span { background: var(--amber); color: #1a1204; }
.steps li.done { opacity: 0.55; }
.steps li.done span { background: var(--teal); color: #04140f; }
.hint { display: flex; gap: 10px; align-items: flex-start; background: #0f1826; border: 1px solid var(--line); border-left: 3px solid var(--teal); border-radius: 6px; padding: 10px 12px; }
.hint span { font-family: Rajdhani, sans-serif; font-weight: 700; color: var(--teal); text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.85em; padding-top: 2px; }
.hint p { margin: 0; font-size: 0.95em; }

/* ---------- help ---------- */
.help-grid { display: grid; grid-template-columns: 1fr 1.3fr; gap: 24px; margin-top: 10px; }
.keys { border-collapse: collapse; width: 100%; }
.keys td { padding: 5px 0; border-bottom: 1px solid #1a2536; color: #c7d3df; }
.keys td:first-child { white-space: nowrap; padding-right: 10px; }
kbd { font-family: Rajdhani, sans-serif; font-weight: 700; background: #1b2638; border: 1px solid #2c3b55; border-bottom-width: 2px; border-radius: 4px; padding: 1px 6px; margin-right: 2px; font-size: 0.9em; color: var(--text); }
.phases { padding-left: 18px; margin: 0; color: #c7d3df; line-height: 1.45; }
.phases li { margin-bottom: 7px; }
.phases b { color: var(--text); }

/* ---------- select ---------- */
.select-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-top: 12px; }
.sel-card { background: #0f1826; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.sel-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.sel-head b { display: block; font-family: Rajdhani, sans-serif; font-size: 1.15em; }
.sel-head small { color: var(--muted); }
.sel-num { width: 28px; height: 28px; border-radius: 6px; background: var(--amber); color: #1a1204; display: grid; place-items: center; font-weight: 700; font-family: Rajdhani, sans-serif; }
.sel-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-family: Rajdhani, sans-serif; font-weight: 600; font-size: 0.88em; color: var(--text); background: #18243a; border: 1px solid var(--line); border-radius: 16px; padding: 4px 10px; cursor: pointer; }
.chip:hover, .chip:focus-visible { border-color: var(--teal); color: #fff; outline: none; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 14px 0 0; }
.stats dt { color: var(--muted); font-family: Rajdhani, sans-serif; text-transform: uppercase; letter-spacing: 0.08em; }
.stats dd { margin: 0; text-align: right; font-family: Rajdhani, sans-serif; font-weight: 700; font-size: 1.15em; }
.win h2 { color: var(--amber-2); }

/* ---------- touch ---------- */
#touch { display: none; position: absolute; inset: 0; pointer-events: none; z-index: 5; }
body.touch #touch { display: block; }
#touch button { pointer-events: auto; -webkit-user-select: none; user-select: none; touch-action: none; border: 1px solid rgba(255, 255, 255, 0.18); background: rgba(12, 19, 31, 0.45); color: rgba(255, 255, 255, 0.8); border-radius: 50%; font-family: Rajdhani, sans-serif; font-weight: 700; }
#touch button.down { background: rgba(224, 165, 38, 0.55); color: #111; }
.pad { position: absolute; left: 3%; bottom: 6%; width: 22%; aspect-ratio: 1; max-width: 180px; }
.pad button { position: absolute; width: 36%; height: 36%; font-size: 1.1em; }
.t-up { left: 32%; top: 0; } .t-down { left: 32%; bottom: 0; } .t-left { left: 0; top: 32%; } .t-right { right: 0; top: 32%; }
.acts { position: absolute; right: 3%; bottom: 8%; display: flex; gap: 14px; align-items: flex-end; }
.acts button { width: 64px; height: 64px; }
.acts .t-fire { width: 82px; height: 82px; background: rgba(224, 165, 38, 0.3) !important; }
.sys { position: absolute; right: 2%; top: 56px; display: flex; gap: 8px; }
.sys button { width: 38px; height: 38px; border-radius: 8px !important; }

@media (max-width: 700px) {
  .mode-grid { grid-template-columns: 1fr; }
  .mode-card img { display: none; }
  .help-grid { grid-template-columns: 1fr; }
  #logo { font-size: 2.6em; }
}

@media (prefers-reduced-motion: reduce) {
  .modal.open, .card, .title-card, .mode-wrap { animation: none; }
}
