:root {
  --navy: #0b2545;
  --navy2: #123a66;
  --ice: #e8f8ff;
  --teal: #5ec8e5;
  --orange: #ff8a3d;
  --orange-dark: #b04a12;
  --text: #ffffff;
  --muted: #9cc4da;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--navy);
  color: var(--text); font-family: 'Nunito', 'Trebuchet MS', system-ui, sans-serif; font-weight: 700;
  overscroll-behavior: none; user-select: none; -webkit-user-select: none; touch-action: none;
}
h1, h2, h3, .display { font-family: 'Fredoka', 'Trebuchet MS', system-ui, sans-serif; font-weight: 700; margin: 0; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.screen {
  position: fixed; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(var(--safe-t) + 20px) 20px calc(var(--safe-b) + 20px); gap: 14px; text-align: center; z-index: 5;
}
.screen.show { display: flex; }
.screen.dim { background: rgba(6, 22, 42, .62); backdrop-filter: blur(3px); }

.logo { font-size: clamp(44px, 14vw, 72px); line-height: .95; letter-spacing: .5px; color: #fff;
  text-shadow: 0 3px 0 #1a6f96, 0 6px 0 #0d4a6c, 0 12px 24px rgba(0, 0, 0, .45); }
.logo small { display: block; font-size: .42em; letter-spacing: 6px; color: var(--teal); text-shadow: 0 2px 8px rgba(0,0,0,.5); margin-bottom: 6px; }
.tag { color: var(--ice); font-size: 17px; max-width: 320px; line-height: 1.35; text-shadow: 0 2px 8px rgba(0,0,0,.5); }

.btn {
  font-family: 'Fredoka', system-ui, sans-serif; font-weight: 700; font-size: 20px; min-height: 52px; padding: 0 26px;
  border-radius: 16px; border: 2px solid var(--teal); background: var(--navy2); color: #fff; cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,.35); transition: transform .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.35); }
.btn.primary { background: linear-gradient(#ffa45e, #ff8a3d); border-color: #ffc59a; color: var(--navy); min-width: 220px; }
.btn.ghost { background: rgba(18, 58, 102, .75); }
.btn[hidden] { display: none; }
.btn-row { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.btn.install { border-color: #ffc59a; color: #ffe2cc; }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: min(420px, 100%); }
.card {
  background: linear-gradient(#1b4f80, #123a66); border: 2px solid #3b82b3; border-radius: 20px; padding: 8px 8px 12px;
  cursor: pointer; text-align: center; color: #fff; font: inherit; box-shadow: 0 5px 0 rgba(0,0,0,.35);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.card:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.35); }
.card canvas { width: 100%; height: 118px; display: block; }
.card .nm { font-family: 'Fredoka', system-ui, sans-serif; font-size: 22px; line-height: 1; }
.card .tg { font-size: 13px; color: var(--muted); }
.stat { display: flex; align-items: center; gap: 6px; width: 100%; font-size: 12px; color: var(--ice); }
.stat span { width: 44px; text-align: left; }
.stat i { flex: 1; height: 7px; border-radius: 4px; background: rgba(0,0,0,.35); position: relative; overflow: hidden; }
.stat i b { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: linear-gradient(90deg, var(--teal), #b6f0ff); }

.pill { background: rgba(18, 58, 102, .88); color: var(--ice); padding: 6px 12px; border-radius: 999px; font-size: 14px; font-weight: 800;
  border: 1px solid rgba(94, 200, 229, .35); backdrop-filter: blur(4px); }

.modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(4, 14, 28, .72); z-index: 30; padding: 20px; }
.modal.open { display: flex; }
.modal-card { background: #123a66; border: 2px solid var(--teal); border-radius: 22px; padding: 22px; width: min(380px, 100%); text-align: left;
  display: flex; flex-direction: column; gap: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.5); }
.modal-card h2 { font-size: 26px; }
.modal-body { font-size: 16px; line-height: 1.45; color: var(--ice); }
.modal-body ol, .modal-body ul { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.modal-body .small { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.modal-card .btn { align-self: stretch; }

.toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 150px); transform: translateX(-50%); background: rgba(11,37,69,.92);
  border: 1px solid var(--teal); padding: 8px 16px; border-radius: 999px; z-index: 20; font-size: 15px; pointer-events: none; opacity: 0; transition: opacity .25s; }
.toast.show { opacity: 1; }

.iconbtn { position: fixed; top: calc(var(--safe-t) + 10px); width: 44px; height: 44px; border-radius: 14px; border: 2px solid rgba(94,200,229,.5);
  background: rgba(18,58,102,.8); color: #fff; font-size: 20px; z-index: 12; cursor: pointer; display: none; align-items: center; justify-content: center; }
.iconbtn.show { display: flex; }
.iconbtn svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
