/* style.css — база: тема (светлая/тёмная), типографика, кнопки, карточки, оверлеи игры */
:root {
  --font: 'Nunito', ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --sky1: #8fd0ff; --sky2: #e4f3ff;
  --ink: #14233f; --muted: #5d7096;
  --card: #ffffff; --card2: #eef5ff; --line: rgba(20, 35, 63, 0.1);
  --brand: #2f78d0; --brand-d: #1b4f9b; --brand-l: #5aa8ff;
  --gold: #f5b301; --ok: #22c55e; --bad: #ef4444;
  --shadow: 0 6px 18px rgba(25, 70, 140, 0.15), 0 1px 3px rgba(25, 70, 140, 0.12);
  --bar: rgba(255, 255, 255, 0.94);
  --overlay: rgba(14, 28, 56, 0.55);
  --r-common: #9aa3b2; --r-rare: #3b82f6; --r-epic: #a855f7; --r-legendary: #f5b301; --r-mythic: #ef4444;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}
:root[data-theme='dark'] {
  --sky1: #12305a; --sky2: #0a1426;
  --ink: #eaf1ff; --muted: #8fa5cd;
  --card: #16233d; --card2: #1e2f50; --line: rgba(255, 255, 255, 0.09);
  --brand: #3b8cf0; --brand-d: #1d56b0; --brand-l: #6fb0ff;
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --bar: rgba(13, 24, 44, 0.95);
  --overlay: rgba(2, 8, 20, 0.7);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none;
  background: var(--sky2); color: var(--ink);
  font-family: var(--font); font-weight: 700;
  user-select: none; -webkit-user-select: none;
}
#app { position: fixed; inset: 0; background: linear-gradient(180deg, var(--sky1), var(--sky2) 60%); }
#game { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
.hidden { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 900; letter-spacing: -0.01em; }
h1 { font-size: 30px; } h2 { font-size: 22px; } h3 { font-size: 17px; }
p { margin: 0; color: var(--muted); font-weight: 700; }
button { font-family: inherit; cursor: pointer; border: 0; color: inherit; background: none; padding: 0; }
svg { display: block; }

/* кнопки: «объёмные», с нижней гранью */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  padding: 14px 18px; font-size: 17px; font-weight: 900; color: #fff; border-radius: 16px;
  background: linear-gradient(180deg, #5aa8ff, #2f78d0); box-shadow: 0 4px 0 #1b4f9b, 0 10px 18px rgba(47, 120, 208, 0.3);
  transition: transform 0.08s, box-shadow 0.08s, opacity 0.2s;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #1b4f9b, 0 4px 10px rgba(47, 120, 208, 0.25); }
.btn:disabled { opacity: 0.45; filter: grayscale(0.4); }
.btn.sec { color: var(--ink); background: var(--card); box-shadow: 0 4px 0 var(--line), var(--shadow); }
.btn.sec:active:not(:disabled) { box-shadow: 0 1px 0 var(--line); }
.btn.gold { color: #4a3000; background: linear-gradient(180deg, #ffe27a, #f5b301); box-shadow: 0 4px 0 #b57f00, 0 10px 18px rgba(245, 179, 1, 0.35); }
.btn.gold:active:not(:disabled) { box-shadow: 0 1px 0 #b57f00; }
.btn.green { background: linear-gradient(180deg, #4ade80, #16a34a); box-shadow: 0 4px 0 #0e7a37, 0 10px 18px rgba(22, 163, 74, 0.3); }
.btn.green:active:not(:disabled) { box-shadow: 0 1px 0 #0e7a37; }
.btn.big { font-size: 20px; padding: 17px 18px; border-radius: 20px; }
.btn.small { width: auto; padding: 9px 14px; font-size: 14px; border-radius: 12px; }
.btn svg { width: 20px; height: 20px; }

.card { background: var(--card); border-radius: 22px; box-shadow: var(--shadow); padding: 16px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; }
.stack { display: flex; flex-direction: column; align-items: stretch; gap: 12px; width: 100%; }

/* игровые экраны поверх холста: онлайн, пауза, итог */
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: calc(20px + var(--safe-top)) 20px calc(20px + var(--safe-bottom));
}
.screen.sub { background: linear-gradient(180deg, var(--sky1), var(--sky2) 60%); z-index: 10; overflow-y: auto; justify-content: flex-start; }
.screen.sub > * { width: min(380px, 100%); }
.screen.sub h2 { text-align: center; margin-bottom: 4px; }
.overlay { background: var(--overlay); z-index: 20; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal-card { width: min(360px, 100%); background: var(--card); border-radius: 26px; box-shadow: var(--shadow); padding: 22px 18px 18px; display: flex; flex-direction: column; gap: 12px; align-items: stretch; text-align: center; }

.hud-btn {
  position: absolute; z-index: 3; top: calc(10px + var(--safe-top)); width: 42px; height: 42px; padding: 0;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.82); color: #16233b; box-shadow: 0 2px 8px rgba(20, 40, 80, 0.25);
}
#pauseBtn { right: 12px; }
#soundBtn { right: 62px; }
#soundBtn .mute { display: none; }
#soundBtn.off .wave { display: none; }
#soundBtn.off .mute { display: inline; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input {
  width: 100%; padding: 13px 14px; font: inherit; font-size: 17px; font-weight: 800; border: 2px solid transparent; border-radius: 14px;
  background: var(--card); color: var(--ink); outline: none; user-select: text; -webkit-user-select: text; box-shadow: var(--shadow);
}
input:focus { border-color: var(--brand); }
.code { font-size: 54px; font-weight: 900; letter-spacing: 0.18em; padding-left: 0.18em; text-align: center; color: var(--brand); font-variant-numeric: tabular-nums; }
.code-in { text-align: center; text-transform: uppercase; font-size: 38px; }
.pair { font-size: 22px; font-weight: 900; text-align: center; padding: 30px 0; white-space: pre-line; line-height: 1.6; }
.err { color: var(--bad); min-height: 1.2em; text-align: center; font-size: 14px; }
.sub-note { text-align: center; font-size: 14px; }

.pop { animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
@keyframes pop { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fadeUp { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: 0.01s !important; transition-duration: 0.01s !important; } }
