/* PastIce — neon fire-vs-frost UI: glassy dark panels, cyan edges, Chakra Petch. */
:root {
  --bg: #0b0616;
  --panel: rgba(20, 11, 38, 0.72);
  --panel-solid: rgba(20, 11, 38, 0.92);
  --edge: rgba(95, 243, 255, 0.32);
  --edge-soft: rgba(95, 243, 255, 0.16);
  --text: #efe8ff;
  --muted: #a99cc9;
  --fire: #ff7a2f;
  --fire-hot: #ffcf5a;
  --frost: #5ff3ff;
  --mint: #6dffc4;
  --door: #d05cff;
  --font: 'Chakra Petch', ui-rounded, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); overflow: hidden; -webkit-font-smoothing: antialiased; }
body { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
canvas#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; z-index: 1; }
[hidden] { display: none !important; }

/* ---------- screens & panels ---------- */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.screen.dim { background: rgba(5, 2, 12, 0.5); }
.panel {
  position: relative;
  background: linear-gradient(160deg, rgba(40, 20, 70, 0.78), rgba(14, 8, 28, 0.82));
  border: 1px solid var(--edge); border-radius: 18px;
  -webkit-backdrop-filter: blur(10px) saturate(130%); backdrop-filter: blur(10px) saturate(130%);
  padding: 28px 28px 22px; max-width: 560px; width: 100%; text-align: center;
  box-shadow: 0 0 0 1px rgba(208, 92, 255, 0.08) inset, 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 50px rgba(95, 243, 255, 0.1);
}
/* a thin fire→frost light strip along the top edge */
.panel::before { content: ''; position: absolute; left: 18px; right: 18px; top: -1px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--fire), var(--fire-hot) 40%, var(--frost) 60%, transparent); opacity: 0.85; }
.panel.small { max-width: 390px; display: flex; flex-direction: column; gap: 10px; }
.panel.wide { max-width: 720px; }
.panel.slim { padding: 14px 20px 16px; max-width: 680px; }
h1, h2 { margin: 0 0 12px; letter-spacing: 0.08em; }
h2 { font-size: 22px; }
p { margin: 0 0 12px; line-height: 1.45; color: var(--muted); font-size: 15px; }
.row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }

.logo { font-size: clamp(46px, 12vw, 80px); font-weight: 700; letter-spacing: 0.06em; line-height: 1; margin-bottom: 14px; }
.logo.small { font-size: clamp(28px, 7vw, 44px); }
.logo .fire { color: var(--fire); text-shadow: 0 0 10px rgba(255, 122, 47, 0.9), 0 0 34px rgba(255, 122, 47, 0.5); }
.logo .frost { color: var(--frost); text-shadow: 0 0 10px rgba(95, 243, 255, 0.9), 0 0 34px rgba(95, 243, 255, 0.5); }
.tag { color: var(--text); opacity: 0.86; }
.keys { font-size: 13px; margin-top: 14px; }
.ver { font-size: 12px; opacity: 0.5; margin: 0; }

.legend { list-style: none; padding: 0; margin: 14px auto 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; text-align: left; max-width: 470px; }
.legend li { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.legend b { color: var(--text); margin-right: 4px; }
@media (max-width: 480px) { .legend { grid-template-columns: 1fr; } }
.tile { flex: 0 0 26px; height: 26px; border-radius: 5px; display: inline-block; position: relative; }
.t-fire { background: linear-gradient(180deg, #ffcf5a, #ff5a1f); box-shadow: 0 0 12px rgba(255, 122, 47, 0.65); }
.t-fire::after { content: '▲'; position: absolute; inset: 0; display: grid; place-items: center; color: #fff5; font-size: 12px; }
.t-frost { background: rgba(42, 212, 255, 0.4); border: 1.5px solid var(--frost); box-shadow: 0 0 10px rgba(95, 243, 255, 0.35); }
.t-frost::after { content: '◇'; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 15px; }
.t-ice { background: rgba(170, 240, 255, 0.3); border: 2px solid #bff6ff; }
.t-ice::after { content: '❄'; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 14px; }
.t-plate { height: 7px; margin-top: 19px; background: var(--frost); box-shadow: 0 0 12px var(--frost); }

.btn {
  font-family: var(--font); font-weight: 700; font-size: 17px; letter-spacing: 0.1em;
  color: var(--text); background: rgba(95, 243, 255, 0.07); border: 1px solid var(--edge);
  padding: 12px 22px; border-radius: 12px; cursor: pointer; min-width: 140px; min-height: 48px;
  transition: transform 0.08s, background 0.15s, box-shadow 0.15s;
}
.btn:hover, .btn:focus-visible { background: rgba(95, 243, 255, 0.16); box-shadow: 0 0 18px rgba(95, 243, 255, 0.35); outline: none; }
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(90deg, rgba(255, 122, 47, 0.38), rgba(95, 243, 255, 0.34)); border-color: var(--mint);
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.35); }
.btn.primary:hover, .btn.primary:focus-visible { box-shadow: 0 0 22px rgba(109, 255, 196, 0.45); }
.btn:disabled { opacity: 0.3; cursor: default; box-shadow: none; }

/* level select */
.tabs { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
.tab { font: 700 13px var(--font); letter-spacing: 0.06em; color: var(--muted); background: transparent; border: 1px solid var(--edge-soft);
  border-radius: 999px; padding: 7px 13px; cursor: pointer; min-height: 34px; }
.tab[aria-selected="true"] { color: var(--text); background: rgba(95, 243, 255, 0.18); border-color: var(--frost); box-shadow: 0 0 12px rgba(95, 243, 255, 0.3); }
.tab:focus-visible { outline: 2px solid var(--frost); }
.level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 4px 0 14px; }
.level-grid .btn { min-width: 0; padding: 10px 4px; font-size: 18px; min-height: 58px; }
.level-grid .btn small { display: block; font-size: 10px; font-weight: 500; letter-spacing: 0.04em; opacity: 0.72; margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.level-grid .btn.done { border-color: rgba(109, 255, 196, 0.6); }
.level-grid .endless { grid-column: 1 / -1; }
@media (max-width: 520px) { .level-grid { grid-template-columns: repeat(4, 1fr); } }

/* dice */
.dice-screen { flex-direction: column; justify-content: space-between; padding: max(20px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom)); pointer-events: none; }
.dice-screen > * { pointer-events: auto; }
.dice-num { font-size: 12px; font-weight: 700; letter-spacing: 0.22em; color: var(--muted); }
.dice-level { font-size: clamp(24px, 5.5vw, 36px); font-weight: 700; letter-spacing: 0.1em; color: var(--text); text-shadow: 0 0 18px rgba(95, 243, 255, 0.35); }
.dice-hint { margin-top: 6px; font-size: 15px; color: var(--frost); line-height: 1.4; }
.dice-hint .new { display: inline-block; margin-right: 8px; padding: 2px 8px; border-radius: 999px; background: var(--mint); color: #003322;
  font-size: 11px; font-weight: 700; letter-spacing: 0.12em; vertical-align: 2px; box-shadow: 0 0 12px rgba(109, 255, 196, 0.6); }
.dice-bottom { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.dice-result { min-height: 26px; font-size: 19px; font-weight: 700; letter-spacing: 0.08em; color: var(--fire-hot);
  text-shadow: 0 0 14px rgba(255, 207, 90, 0.55), 0 2px 8px rgba(0, 0, 0, 0.8); text-align: center; }

/* HUD: one row even on phones */
#hud { position: fixed; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); z-index: 5; pointer-events: none; }
#hud > * { pointer-events: auto; }
.hud-left { display: flex; gap: 8px; align-items: center; min-width: 0; flex: 1 1 auto; }
.hud-right { display: flex; gap: 6px; flex: 0 0 auto; }
.chip { background: var(--panel); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border: 1px solid var(--edge); border-radius: 10px;
  padding: 8px 12px; font-size: 14px; font-weight: 700; letter-spacing: 0.08em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#hud-level { flex: 0 1 auto; }
.echo-chip { color: var(--frost); flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.icon { font-family: var(--font); width: 42px; height: 42px; border-radius: 11px; background: var(--panel); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border: 1px solid var(--edge); color: var(--text); font-size: 17px; font-weight: 700; cursor: pointer; }
.icon:hover, .icon:focus-visible { box-shadow: 0 0 14px rgba(95, 243, 255, 0.4); outline: none; }
.icon.off { opacity: 0.45; text-decoration: line-through; }
@media (max-width: 560px) {
  .chip { font-size: 12px; padding: 7px 9px; letter-spacing: 0.04em; }
  .icon { width: 38px; height: 38px; font-size: 15px; }
  #hud-echo { display: none; }
}

.toast { position: fixed; left: 50%; top: max(110px, calc(env(safe-area-inset-top) + 106px)); transform: translateX(-50%); z-index: 6;
  max-width: min(680px, calc(100vw - 32px)); text-align: center; background: var(--panel-solid); border: 1px solid var(--edge); border-radius: 12px;
  padding: 10px 16px; font-size: 15px; font-weight: 700; letter-spacing: 0.05em; color: var(--frost); opacity: 0; transition: opacity 0.35s; pointer-events: none; }
.toast.show { opacity: 1; }
.banner { position: fixed; left: 50%; top: max(62px, calc(env(safe-area-inset-top) + 58px)); transform: translateX(-50%); z-index: 6; white-space: nowrap;
  background: rgba(95, 243, 255, 0.16); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border: 1.5px solid var(--frost); color: var(--frost);
  border-radius: 12px; padding: 8px 16px; font-weight: 700; font-size: clamp(12px, 3.2vw, 16px); letter-spacing: 0.08em; animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 22px rgba(95, 243, 255, 0.55); } }

/* level title card, fades in and out at the start of each level */
.titlecard { position: fixed; left: 0; right: 0; top: 36%; z-index: 4; text-align: center; pointer-events: none; opacity: 0; transition: opacity 0.6s; }
.titlecard.show { opacity: 1; }
.titlecard small { display: block; font-size: 14px; font-weight: 700; letter-spacing: 0.3em; color: var(--frost); margin-bottom: 6px; text-shadow: 0 0 12px rgba(95, 243, 255, 0.6); }
.titlecard span { font-size: clamp(30px, 7vw, 58px); font-weight: 700; letter-spacing: 0.1em; color: #fff;
  text-shadow: 0 0 18px rgba(255, 122, 47, 0.7), 0 0 44px rgba(95, 243, 255, 0.35), 0 4px 20px rgba(0, 0, 0, 0.8); }
@media (prefers-reduced-motion: reduce) { .banner { animation: none; } }
