/* StormShelter - UI styles. Copyright (C) 2026 Shawn Rapaz. GPL-3.0 */
:root {
  --ink: #23324a;
  --ink-soft: #4b5d78;
  --paper: #fffaf0;
  --panel: rgba(255, 252, 244, 0.96);
  --green: #4cc75a; --green-d: #2f9a3e;
  --blue: #43a6f5; --blue-d: #2477c4;
  --purple: #a678f0; --purple-d: #7748c8;
  --orange: #ffa53b; --orange-d: #d9771a;
  --red: #ff6b6b; --red-d: #cc4141;
  --yellow: #ffd23f;
  --shadow: 0 10px 30px rgba(20, 30, 60, 0.25);
}
* { box-sizing: border-box; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0f1b2b; font-family: 'Fredoka', 'Comic Sans MS', system-ui, sans-serif; color: var(--ink); }
#stage { position: absolute; left: 0; top: 0; width: 1280px; height: 720px; transform-origin: 0 0; overflow: hidden; }
#game { position: absolute; left: 0; top: 0; width: 1280px; height: 720px; touch-action: none; }
.hidden { display: none !important; }

/* ---------- screens ---------- */
.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: block; animation: fadeIn .35s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.screen.hud { pointer-events: none; }
.screen.hud > * { pointer-events: auto; }
.screen.hud > .storm-count, .screen.hud > .storm-banner { pointer-events: none; }

/* ---------- buttons ---------- */
.btn {
  font-family: inherit; font-weight: 600; font-size: 22px; color: #fff; cursor: pointer;
  border: 0; border-radius: 18px; padding: 12px 22px; background: var(--blue);
  box-shadow: 0 6px 0 var(--blue-d), 0 10px 18px rgba(0,0,0,.2);
  transition: transform .08s ease, box-shadow .08s ease, filter .15s; text-shadow: 0 2px 0 rgba(0,0,0,.18);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
}
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--blue-d), 0 3px 8px rgba(0,0,0,.2); }
.btn:focus-visible { outline: 4px solid #fff; outline-offset: 3px; }
.btn.green { background: var(--green); box-shadow: 0 6px 0 var(--green-d), 0 10px 18px rgba(0,0,0,.2); }
.btn.green:active { box-shadow: 0 1px 0 var(--green-d); }
.btn.purple { background: var(--purple); box-shadow: 0 6px 0 var(--purple-d), 0 10px 18px rgba(0,0,0,.2); }
.btn.purple:active { box-shadow: 0 1px 0 var(--purple-d); }
.btn.orange { background: var(--orange); box-shadow: 0 6px 0 var(--orange-d), 0 10px 18px rgba(0,0,0,.2); }
.btn.orange:active { box-shadow: 0 1px 0 var(--orange-d); }
.btn.red { background: var(--red); box-shadow: 0 6px 0 var(--red-d), 0 10px 18px rgba(0,0,0,.2); }
.btn.red:active { box-shadow: 0 1px 0 var(--red-d); }
.btn.ghost { background: rgba(255,255,255,.22); box-shadow: none; font-size: 17px; padding: 8px 16px; backdrop-filter: blur(4px); }
.btn.big { font-size: 40px; padding: 16px 60px; border-radius: 26px; }
.btn.round { width: 58px; height: 58px; padding: 0; border-radius: 50%; font-size: 26px; background: #fff; color: var(--ink); text-shadow: none; box-shadow: 0 5px 0 #b9c6d8, 0 8px 16px rgba(0,0,0,.2); }
.btn.round:active { box-shadow: 0 1px 0 #b9c6d8; }
.btn.round.tiny { width: 38px; height: 38px; font-size: 18px; box-shadow: 0 3px 0 #b9c6d8; }
.btn.toggle { background: #fff; color: var(--ink); text-shadow: none; box-shadow: 0 6px 0 #b9c6d8, 0 10px 18px rgba(0,0,0,.15); min-width: 220px; }
.btn.toggle.off { color: #8a97ab; }
.btn:disabled { filter: grayscale(.8) brightness(.95); cursor: default; opacity: .6; }
.i { width: 1.1em; height: 1.1em; vertical-align: -0.2em; flex: none; display: inline-block; }
.btn .i { width: 1.05em; height: 1.05em; }
.btn.round .i { width: 26px; height: 26px; }
.btn.round.tiny .i { width: 18px; height: 18px; }
.btn.done span .i { width: 26px; height: 26px; }
.lvl .i.lock { width: 34px; height: 34px; }
.lvl small { display: flex; gap: 1px; }
.lvl small .i { width: 14px; height: 14px; }
.wind-arrow .i { width: 34px; height: 34px; }
.timer span .i { width: 40px; height: 40px; }
.why .big .i { width: 54px; height: 54px; }
.panel .stars .s .i { width: 84px; height: 84px; vertical-align: middle; }
.panel .stars .s:not(.on) .i { filter: grayscale(1) opacity(.35); }
.storm-tabs .i, .lvl-chip .i { width: 22px; height: 22px; }
.warn-scroll .i { width: 26px; height: 26px; vertical-align: -6px; }
.storm-banner .i { width: 34px; height: 34px; vertical-align: -7px; }
.toast .i { width: 26px; height: 26px; vertical-align: -6px; }
table.hist .i { width: 14px; height: 14px; }

/* ---------- title ---------- */
#title { background: radial-gradient(ellipse at 50% 20%, rgba(255,255,255,.18), rgba(255,255,255,0) 60%); }
.logo { position: absolute; top: 34px; left: 0; right: 0; text-align: center; animation: float 4s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.logo-icon { width: 120px; height: 100px; filter: drop-shadow(0 6px 10px rgba(0,0,0,.2)); }
.logo h1 { margin: -6px 0 0; font-size: 96px; font-weight: 700; letter-spacing: 1px; line-height: 1; }
.logo h1 span { display: inline-block; -webkit-text-stroke: 3px #1f3354; paint-order: stroke fill; text-shadow: 0 6px 0 #1f3354, 0 12px 24px rgba(0,0,0,.25); }
.logo .l1 { color: #ffd23f; transform: rotate(-3deg); }
.logo .l2 { color: #ffffff; transform: rotate(2deg); margin-left: 8px; }
.tagline { margin: 12px 0 0; font-size: 26px; color: #fff; font-weight: 500; text-shadow: 0 2px 6px rgba(0,0,0,.45); }
.title-menu { position: absolute; top: 330px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.title-menu .row { display: flex; gap: 16px; }
.title-menu .row.small { gap: 10px; margin-top: 2px; }
.seg { display: flex; background: rgba(255,255,255,.9); border-radius: 22px; padding: 6px; box-shadow: 0 6px 0 #b9c6d8, 0 10px 18px rgba(0,0,0,.15); }
.seg button { font-family: inherit; font-size: 21px; font-weight: 600; border: 0; background: transparent; color: var(--ink-soft); padding: 10px 20px; border-radius: 16px; cursor: pointer; }
.seg button.on { background: var(--orange); color: #fff; box-shadow: inset 0 -4px 0 var(--orange-d); }
.seg button[data-diff="easy"].on { background: var(--green); box-shadow: inset 0 -4px 0 var(--green-d); }
.seg button[data-diff="hard"].on { background: var(--red); box-shadow: inset 0 -4px 0 var(--red-d); }
.age-badge { position: absolute; left: 28px; top: 26px; width: 92px; height: 92px; border-radius: 50%; background: var(--yellow); border: 5px solid #fff; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center; transform: rotate(-10deg); color: #6b4a00; }
.age-badge b { font-size: 36px; line-height: 1; }
.age-badge span { font-size: 15px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }
.version { position: absolute; right: 18px; bottom: 12px; color: rgba(255,255,255,.85); font-size: 15px; text-shadow: 0 1px 3px rgba(0,0,0,.5); }

/* ---------- generic screen header ---------- */
.screen-head { position: absolute; top: 18px; left: 22px; right: 22px; display: flex; align-items: center; gap: 18px; }
.screen-head h2 { margin: 0; font-size: 46px; color: #fff; -webkit-text-stroke: 2px #1f3354; paint-order: stroke fill; text-shadow: 0 4px 0 #1f3354; flex: 1; }
.diff-pill, .head-stats { background: rgba(255,255,255,.92); border-radius: 18px; padding: 8px 18px; font-size: 20px; font-weight: 600; box-shadow: var(--shadow); }

/* ---------- save slots ---------- */
.slot-list { position: absolute; top: 120px; left: 60px; right: 60px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; }
.slot { background: var(--panel); border-radius: 28px; padding: 22px; box-shadow: var(--shadow); min-height: 420px; display: flex; flex-direction: column; align-items: center; text-align: center; border: 5px solid #fff; position: relative; }
.slot h3 { margin: 0; font-size: 30px; }
.slot .avatar { width: 120px; height: 120px; margin: 10px 0; }
.slot .meta { font-size: 19px; color: var(--ink-soft); line-height: 1.55; flex: 1; }
.slot .meta b { color: var(--ink); }
.slot .stars-big { font-size: 28px; color: #c48a10; font-weight: 700; }
.slot .actions { display: flex; gap: 10px; margin-top: 10px; }
.slot.empty { background: rgba(255,255,255,.55); border-style: dashed; }
.slot.empty .meta { display: flex; align-items: center; justify-content: center; font-size: 22px; }
.slot .del { position: absolute; top: 12px; right: 12px; }

/* ---------- level select ---------- */
.resume-bar { position: absolute; top: 96px; left: 50%; transform: translateX(-50%); background: var(--panel); border-radius: 20px; padding: 8px 10px 8px 20px; display: flex; align-items: center; gap: 16px; font-size: 20px; font-weight: 600; box-shadow: var(--shadow); z-index: 2; }
.resume-bar .btn { font-size: 19px; padding: 8px 16px; }
.storm-tabs { position: absolute; top: 160px; left: 40px; right: 40px; display: flex; gap: 10px; justify-content: center; }
.storm-tabs button { font-family: inherit; font-size: 19px; font-weight: 600; border: 0; border-radius: 16px 16px 6px 6px; padding: 10px 16px; cursor: pointer; background: rgba(255,255,255,.6); color: var(--ink); }
.storm-tabs button.on { background: #fff; box-shadow: 0 -4px 0 inset var(--orange); }
.level-grid { position: absolute; top: 214px; left: 50%; transform: translateX(-50%); width: 980px; display: grid; grid-template-columns: repeat(10, 1fr); gap: 14px; padding: 22px; background: rgba(255,255,255,.9); border-radius: 26px; box-shadow: var(--shadow); }
.lvl { font-family: inherit; aspect-ratio: 1; border: 0; border-radius: 18px; cursor: pointer; font-size: 28px; font-weight: 700; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; text-shadow: 0 2px 0 rgba(0,0,0,.2); transition: transform .1s; }
.lvl:hover { transform: scale(1.06); }
.lvl small { font-size: 12px; letter-spacing: 1px; color: #ffe27a; text-shadow: 0 1px 0 rgba(0,0,0,.35); height: 14px; }
.lvl.locked { background: #c9d2de !important; box-shadow: 0 5px 0 #a3afbf !important; color: #8a97ab; cursor: default; text-shadow: none; }
.lvl.locked:hover { transform: none; }
.lvl.current { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.lvl.s-wind { background: #5bb8f5; box-shadow: 0 5px 0 #3a8fd0; }
.lvl.s-gale { background: #4fc4a6; box-shadow: 0 5px 0 #2f9a80; }
.lvl.s-thunder { background: #8b7cf0; box-shadow: 0 5px 0 #6252c8; }
.lvl.s-tornado { background: #f0a24f; box-shadow: 0 5px 0 #c87a28; }
.lvl.s-hurricane { background: #f26d7d; box-shadow: 0 5px 0 #c84556; }

/* ---------- HUD ---------- */
.hud-top { position: absolute; top: 14px; left: 14px; right: 14px; display: flex; align-items: center; gap: 12px; }
.lvl-chip { background: rgba(255,255,255,.92); border-radius: 18px; padding: 6px 16px; display: flex; flex-direction: column; line-height: 1.1; box-shadow: var(--shadow); min-width: 140px; }
.lvl-chip span { font-size: 22px; font-weight: 700; }
.lvl-chip small { font-size: 15px; color: var(--ink-soft); font-weight: 600; }
.warning { flex: 1; height: 50px; border-radius: 14px; overflow: hidden; position: relative; background: repeating-linear-gradient(-45deg, #ffd23f 0 22px, #2a2a2a 22px 44px); box-shadow: var(--shadow); padding: 5px; }
.warning::before { content: ''; position: absolute; inset: 5px; background: #fff3c4; border-radius: 9px; }
.warn-scroll { position: absolute; top: 5px; bottom: 5px; white-space: nowrap; font-size: 22px; font-weight: 700; color: #8a3a00; line-height: 40px; animation: scroll 16s linear infinite; padding-left: 100%; }
@keyframes scroll { from { transform: translateX(0); } to { transform: translateX(-100%); } }
.warning.storm { background: repeating-linear-gradient(-45deg, #ff5a5a 0 22px, #2a2a2a 22px 44px); }
.warning.storm::before { background: #ffe0e0; }
.wind-chip { background: rgba(255,255,255,.92); border-radius: 18px; width: 86px; height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: var(--shadow); }
.wind-arrow { font-size: 30px; color: #2477c4; line-height: 1; transition: transform .4s; animation: windwiggle 1s ease-in-out infinite; }
@keyframes windwiggle { 0%,100% { translate: -3px 0; } 50% { translate: 3px 0; } }
.wind-chip.left .wind-arrow { transform: scaleX(-1); }
.wind-chip.both .wind-arrow::after { content: ''; }
.wind-chip small { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.timer { width: 84px; height: 84px; position: relative; margin: -12px 0; }
.timer > svg { position: absolute; inset: 0; transform: rotate(-90deg); filter: drop-shadow(0 6px 10px rgba(0,0,0,.25)); }
.timer circle.bg { fill: #fff; stroke: #dfe7f1; stroke-width: 9; }
.timer circle.fg { fill: none; stroke: var(--green); stroke-width: 9; stroke-linecap: round; stroke-dasharray: 276.46; transition: stroke .3s; }
.timer span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 34px; font-weight: 700; }
.timer.low circle.fg { stroke: var(--orange); }
.timer.critical circle.fg { stroke: var(--red); }
.timer.critical span { color: var(--red-d); animation: beat .5s ease-in-out infinite; }
@keyframes beat { 50% { transform: scale(1.15); } }

.hint-bubble { position: absolute; top: 92px; left: 50%; transform: translateX(-50%); max-width: 760px; background: #fff; border-radius: 22px; padding: 12px 12px 12px 22px; font-size: 22px; font-weight: 500; box-shadow: var(--shadow); display: flex; align-items: center; gap: 10px; border: 4px solid var(--yellow); animation: pop .4s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop { from { transform: translateX(-50%) scale(.6); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
.hint-bubble span { flex: 1; }

.storm-count { position: absolute; top: 140px; left: 0; right: 0; text-align: center; font-size: 150px; font-weight: 700; color: #fff; -webkit-text-stroke: 5px #1f3354; paint-order: stroke fill; text-shadow: 0 8px 0 #1f3354; }
.storm-count.tick { animation: countPop .5s ease; }
@keyframes countPop { from { transform: scale(1.6); opacity: .3; } to { transform: scale(1); opacity: 1; } }
.storm-banner { position: absolute; top: 96px; left: 50%; transform: translateX(-50%); background: rgba(30,40,60,.85); color: #fff; padding: 10px 28px; border-radius: 20px; font-size: 28px; font-weight: 700; white-space: nowrap; }

.tray { position: absolute; left: 0; right: 0; bottom: 0; height: 146px; display: flex; align-items: center; padding: 0 16px; gap: 16px;
  background: linear-gradient(#a8743f, #7b4f27); border-top: 6px solid #5b3a1c; box-shadow: inset 0 6px 0 rgba(255,255,255,.18); }
.tray.disabled { filter: grayscale(.5) brightness(.8); pointer-events: none; }
.tray-items { flex: 1; display: flex; gap: 12px; align-items: center; overflow: hidden; }
.item { position: relative; width: 104px; height: 112px; background: linear-gradient(#fffaf0, #f2e6cf); border-radius: 18px; box-shadow: 0 5px 0 #c9b48e, 0 8px 14px rgba(0,0,0,.25); display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: grab; touch-action: none; transition: transform .1s; }
.item:hover { transform: translateY(-4px); }
.item canvas { width: 84px; height: 72px; pointer-events: none; }
.item .lbl { font-size: 14px; font-weight: 600; color: var(--ink-soft); pointer-events: none; }
.item .count { position: absolute; top: -8px; right: -8px; min-width: 36px; height: 36px; border-radius: 18px; background: var(--red); color: #fff; font-weight: 700; font-size: 21px; display: flex; align-items: center; justify-content: center; border: 3px solid #fff; padding: 0 6px; pointer-events: none; }
.item.empty { opacity: .4; cursor: default; }
.item.empty .count { background: #9aa6b6; }
.item.bump { animation: bump .3s ease; }
@keyframes bump { 50% { transform: scale(1.15); } }
.tray-actions { display: flex; gap: 12px; align-items: center; }
.btn.done { font-size: 34px; padding: 18px 30px; background: var(--green); box-shadow: 0 7px 0 var(--green-d), 0 12px 20px rgba(0,0,0,.3); border-radius: 24px; }
.btn.done:active { box-shadow: 0 1px 0 var(--green-d); }
.btn.done span { background: #fff; color: var(--green-d); border-radius: 50%; width: 42px; height: 42px; display: inline-flex; align-items: center; justify-content: center; text-shadow: none; }

/* ---------- modal ---------- */
.modal { position: absolute; inset: 0; background: rgba(15, 25, 45, .55); display: flex; align-items: center; justify-content: center; z-index: 10; backdrop-filter: blur(3px); }
.panel { background: var(--panel); border-radius: 32px; padding: 30px 38px; box-shadow: 0 20px 60px rgba(0,0,0,.4); border: 6px solid #fff; max-width: 1100px; max-height: 660px; overflow: auto; animation: panelIn .35s cubic-bezier(.2,1.4,.4,1); text-align: center; }
@keyframes panelIn { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.panel h2 { margin: 0 0 12px; font-size: 44px; }
.panel p { font-size: 22px; margin: 8px 0; color: var(--ink-soft); }
.panel .btns { display: flex; gap: 16px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.panel .stars { font-size: 76px; letter-spacing: 8px; margin: 4px 0; }
.panel .stars .s { display: inline-block; transform: scale(.4); transition: transform .4s cubic-bezier(.2,1.8,.4,1), color .2s; }
.panel .stars .s.on { transform: scale(1); filter: drop-shadow(0 4px 0 #d99a00); }
.panel .stars .s.shown { transform: scale(1); }
.score-line { font-size: 26px; font-weight: 700; color: var(--ink); }
.score-break { font-size: 17px; color: var(--ink-soft); margin-top: 4px; }
.why { display: flex; align-items: center; gap: 16px; background: #fff3d6; border-radius: 20px; padding: 14px 20px; margin: 10px auto; max-width: 620px; text-align: left; font-size: 22px; }
.why .big { font-size: 46px; }
.panel.wide { width: 1080px; text-align: left; }
.panel.wide h2 { text-align: center; }
.tabs { display: flex; gap: 8px; justify-content: center; margin-bottom: 14px; }
.tabs button { font-family: inherit; font-size: 19px; font-weight: 600; border: 0; border-radius: 14px; padding: 8px 18px; background: #e7edf5; color: var(--ink); cursor: pointer; }
.tabs button.on { background: var(--purple); color: #fff; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.card { background: #fff; border-radius: 18px; padding: 14px 18px; box-shadow: 0 3px 10px rgba(0,0,0,.08); }
.card h3 { margin: 0 0 8px; font-size: 21px; }
.stat-row { display: flex; justify-content: space-between; font-size: 17px; padding: 3px 0; border-bottom: 1px dashed #e3e8ef; }
.stat-row:last-child { border-bottom: 0; }
.bar { height: 16px; background: #e7edf5; border-radius: 8px; overflow: hidden; margin: 4px 0 10px; }
.bar > div { height: 100%; border-radius: 8px; background: linear-gradient(90deg, var(--green), #8be08f); }
.bar.m > div { background: linear-gradient(90deg, var(--orange), #ffd08a); }
.bar.h > div { background: linear-gradient(90deg, var(--red), #ffa3a3); }
.mistake { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed #e3e8ef; font-size: 16px; }
.mistake b { font-size: 17px; }
.mistake .n { min-width: 40px; height: 32px; border-radius: 10px; background: #ffe2e2; color: var(--red-d); font-weight: 700; display: flex; align-items: center; justify-content: center; }
.mistake .tip { color: var(--ink-soft); }
table.hist { width: 100%; border-collapse: collapse; font-size: 15px; }
table.hist th { text-align: left; color: var(--ink-soft); font-weight: 600; padding: 4px; border-bottom: 2px solid #e3e8ef; }
table.hist td { padding: 4px; border-bottom: 1px solid #eef2f7; }
.ok { color: var(--green-d); font-weight: 700; }
.bad { color: var(--red-d); font-weight: 700; }
.credits { text-align: center; font-size: 21px; line-height: 1.6; }
.credits .role { color: var(--ink-soft); font-size: 16px; text-transform: uppercase; letter-spacing: 2px; margin-top: 12px; }
.credits .name { font-size: 28px; font-weight: 700; }
.credits a { color: var(--blue-d); font-weight: 600; text-decoration: none; cursor: pointer; }
.credits a:hover { text-decoration: underline; }
.license-box { text-align: left; font-family: monospace; font-size: 13px; white-space: pre-wrap; background: #fff; border-radius: 12px; padding: 14px; max-height: 420px; overflow: auto; -webkit-user-select: text; user-select: text; }
.gate-q { font-size: 40px; font-weight: 700; margin: 10px 0; }
.gate-a { display: flex; gap: 14px; justify-content: center; }
.gate-a .btn { min-width: 100px; font-size: 30px; }
input.name { font-family: inherit; font-size: 26px; padding: 10px 16px; border-radius: 14px; border: 3px solid #cfd8e3; width: 340px; text-align: center; -webkit-user-select: text; user-select: text; }

.toast { position: absolute; left: 50%; bottom: 170px; transform: translateX(-50%) translateY(30px); background: rgba(30,40,60,.92); color: #fff; padding: 12px 26px; border-radius: 18px; font-size: 22px; font-weight: 600; opacity: 0; transition: all .3s; pointer-events: none; z-index: 20; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
