:root {
  --bg: #0b1020;
  --panel: #121833;
  --accent: #5fe3b8;
  --accent-2: #ffd166;
  --danger: #ff5e7e;
  --text: #e7ecff;
  --muted: #99a3c7;
  --good: #67e8a5;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Outfit', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 800px at 70% -10%, #1a2250, var(--bg));
  color: var(--text);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(0,0,0,0));
}
.lang-toggle {
  position: fixed; left: 16px; bottom: 16px; z-index: 20;
  padding: 8px 12px; font-weight: 700;
}
.brand .title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.brand .subtitle {
  font-size: 14px;
  color: var(--accent);
  margin-top: 2px;
  font-family: 'JetBrains Mono', monospace;
}
.round-info { display: flex; gap: 20px; color: var(--muted); }

.layout {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 20px;
  padding: 20px;
}

.left { display: flex; flex-direction: column; gap: 16px; }
.right { display: flex; flex-direction: column; gap: 16px; }

.panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 16px;
  backdrop-filter: blur(6px);
}
.panel-title { font-weight: 700; margin-bottom: 12px; color: var(--accent-2); }

.setup-form { display: grid; gap: 12px; }
.setup-form .row { display: grid; gap: 6px; }
input[type="text"] {
  padding: 10px 12px;
  background: #0f1430;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  color: var(--text);
}
.level-select { display: flex; gap: 16px; }
.mode-select { display: flex; gap: 16px; }
label { font-size: 14px; color: var(--muted); }

.btn {
  appearance: none;
  background: #1a245a;
  color: white;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 0.05s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,0,0,0.25); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, #3860ff, #2b3ddb); }
.btn.success { background: linear-gradient(180deg, #1fbf75, #149a5c); }
.btn.spin.slow { background: linear-gradient(180deg, #ffd166, #e7a82a); color: #141414; }
.btn.spin.fast { background: linear-gradient(180deg, #ff7aa0, #e14976); }

.wheel-area {
  position: relative;
  display: grid;
  place-items: center;
  padding: 8px 0 16px 0;
}
.wheel {
  width: min(85vh, 680px);
  height: min(85vh, 680px);
  filter: drop-shadow(0 20px 50px rgba(0,0,0,0.5));
}
.pointer {
  position: absolute;
  top: 8px;
  width: 0; height: 0;
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-bottom: 26px solid var(--accent-2);
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.5));
  z-index: 2;
}
.wheel-center {
  position: absolute;
  display: flex;
  gap: 10px;
}

.coinflip-panel { display: grid; gap: 10px; align-items: center; justify-items: center; }
.coinflip-panel.disabled { pointer-events: none; }
.coin-container { perspective: 1000px; height: 120px; }
.coin {
  width: 110px; height: 110px; border-radius: 50%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 1s ease-in-out;
  box-shadow: inset 0 4px 8px rgba(255,255,255,0.2), 0 20px 40px rgba(0,0,0,0.4);
}
.coin .face {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  backface-visibility: hidden;
  font-weight: 700; letter-spacing: 1px;
  background: radial-gradient(circle at 30% 30%, #ffd56f, #e3a234);
  color: #1d1200;
}
.coin .back { transform: rotateY(180deg); background: radial-gradient(circle at 70% 70%, #9bd7ff, #4ba0d8); color: #041b2c; }
.coin.flip { animation: flip 1.2s ease-in-out 1; }
@keyframes flip {
  0% { transform: rotateY(0) rotateX(0); }
  50% { transform: rotateY(540deg) rotateX(20deg); }
  100% { transform: rotateY(1080deg) rotateX(0); }
}
.coin-result { min-height: 24px; color: var(--accent); font-weight: 700; }

.solution-card { padding: 0; overflow: hidden; }
.solution-header { padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.08); color: var(--accent); font-weight: 700; }
.division-display {
  margin: 0; padding: 20px; font-family: 'JetBrains Mono', monospace; font-size: 18px;
  line-height: 1.8; color: #f1f5ff; white-space: pre; tab-size: 1;
  letter-spacing: 0; background: rgba(0,0,0,0.1); border-radius: 8px;
}
.division-display .slot { display: inline-block; width: 1ch; text-align: center; vertical-align: bottom; }
.division-display .blank { display: inline-block; width: 1ch; color: #93a2ff; border-bottom: 2px solid #93a2ff; padding: 0; text-align: center; }
.division-display .reveal { display: inline-block; width: 1ch; color: #ffffff; border-bottom: 2px solid transparent; text-align: center; }
.division-display .input-wrap { display: inline-block; position: relative; width: 1ch; text-align: center; }
.division-display .input-wrap .input-echo {
  position: absolute; left: 0; right: 0; text-align: center; pointer-events: none; color: #fff;
  font-weight: 800;
}
.division-display .digit-input {
  width: 1ch; height: 1.8em; text-align: center; font: inherit; color: #fff;
  background: rgba(255,255,255,0.04); border: none; border-bottom: 2px solid #93a2ff; outline: none;
  letter-spacing: 0; caret-color: var(--accent-2); font-weight: 800; border-radius: 4px 4px 0 0;
}
.division-display .digit-input.ok { border-bottom-color: #67e8a5; color: #eafff5; }
.division-display .digit-input.err { border-bottom-color: #ff5e7e; color: #ffd6df; }
.division-display .input-echo.ok { color: #67e8a5; }
.division-display .input-echo.err { color: #ff5e7e; }
.division-display .input-mark { display: none; }
.solve-controls { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.solve-controls input[type="text"]{ flex: 1; padding: 10px 12px; background: #0f1430; border: 1px solid rgba(255,255,255,0.12); border-radius: 10px; color: var(--text); }

.hud .status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.label { color: var(--muted); font-size: 12px; }
.value { font-weight: 700; font-size: 20px; }

.scores { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.score-card { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); border-radius: 12px; padding: 12px; transition: box-shadow 0.2s ease, transform 0.2s ease; }
.score-card.active { box-shadow: 0 8px 24px rgba(95,227,184,0.25); transform: translateY(-2px); }
.score-card .nick { font-weight: 800; color: var(--accent-2); }
.points { font-size: 22px; font-weight: 800; }
.points.total { color: var(--good); }

.unused { margin-top: 8px; }
.digits { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; margin-top: 6px; }
.digits .digit { 
  text-align: center; padding: 8px 0; border-radius: 8px; background: #0f1430; 
  border: 1px dashed rgba(255,255,255,0.12); font-family: 'JetBrains Mono', monospace; 
  cursor: pointer; transition: all 0.15s ease;
}
.digits .digit:hover { background: #172058; transform: translateY(-1px); border-color: var(--accent); }
.digits .digit.used { opacity: 0.35; text-decoration: line-through; cursor: not-allowed; }

/* Pointer bounce when landing */
.pointer.bump { animation: pointer-bump 400ms ease-in-out 1; }
@keyframes pointer-bump {
  0% { transform: translateY(0); }
  30% { transform: translateY(6px); }
  100% { transform: translateY(0); }
}

/* Overlay */
.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,0.6); z-index: 10; }
.overlay-card { width: min(720px, 92vw); background: var(--panel); border: 1px solid rgba(255,255,255,0.12); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.overlay-title { padding: 16px 18px; font-weight: 800; color: var(--accent-2); border-bottom: 1px solid rgba(255,255,255,0.08); }
.overlay-content { padding: 14px 18px; color: var(--text); }
.overlay-content ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.overlay-actions { padding: 12px 18px; border-top: 1px solid rgba(255,255,255,0.08); display: flex; justify-content: end; }

.actions { display: flex; gap: 8px; margin-top: 8px; }
.message { margin-top: 10px; min-height: 22px; color: var(--accent); }

.leaderboard-list { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.leaderboard-list li { padding: 6px 8px; background: rgba(255,255,255,0.04); border-radius: 10px; }

.round-banner {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 24px; padding: 10px 16px; border-radius: 999px;
  background: linear-gradient(90deg, #6fe7bf, #7ad8ff);
  color: #0a0f22; font-weight: 800; letter-spacing: 0.5px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.4);
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .wheel { width: min(70vh, 520px); height: min(70vh, 520px); }
}


