/* ================================================================
   NUMGAME — style.css
   Screens: Start · Game · Pause · End
   ================================================================ */

/* ── TOKENS ───────────────────────────────────────────────────── */
:root {
  --bg:         #07090f;
  --surface:    #0d1018;
  --surface2:   #131720;
  --surface3:   #191e2e;
  --border:     #1c2135;
  --border2:    #263050;

  --neon:       #00f5a0;
  --neon-dim:   rgba(0,245,160,.08);
  --neon-glow:  rgba(0,245,160,.28);

  --hot:        #ff4e50;
  --warm:       #fc913a;
  --cool:       #4fa3e0;
  --cold:       #74b9ff;

  --easy:       #00e676;
  --med:        #00b0ff;
  --hard:       #ff4081;

  --text:       #dde3f4;
  --muted:      #3d4560;
  --muted2:     #606880;

  --sans: 'Space Grotesk', sans-serif;
  --mono: 'Space Mono', monospace;
  --r:    14px;
  --rsm:  9px;
  --transition: .22s cubic-bezier(.4,0,.2,1);
}

/* ── RESET ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100%;
  overflow-x: hidden;
}

/* ── CANVASES ─────────────────────────────────────────────────── */
#bg-canvas, #confetti-canvas {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
}
#confetti-canvas { z-index: 200; }

/* ── SCREENS ──────────────────────────────────────────────────── */
.screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
  transition: opacity var(--transition), transform var(--transition);
}
.screen.hidden { opacity: 0; pointer-events: none; transform: scale(.97); }

.overlay-screen { background: rgba(7,9,15,.82); backdrop-filter: blur(10px); z-index: 50; }

/* ── ══════════════════════════════
   START SCREEN
══════════════════════════════ ── */
#screen-start { overflow-y: auto; align-items: flex-start; padding: 40px 16px 60px; }

.start-inner {
  width: 100%; max-width: 440px;
  margin: auto;
  display: flex; flex-direction: column; gap: 28px;
}

.start-logo {
  font-family: var(--mono);
  font-size: 1rem; font-weight: 700; letter-spacing: .12em;
  color: var(--text);
}
.logo-bracket { color: var(--neon); text-shadow: 0 0 14px var(--neon-glow); }

.start-title {
  font-size: clamp(2.8rem, 10vw, 4rem);
  font-weight: 700; line-height: 1.02; letter-spacing: -.04em;
}
.start-title em {
  font-style: normal; color: var(--neon);
  text-shadow: 0 0 40px var(--neon-glow);
}

.start-sub {
  color: var(--muted2); font-size: .93rem; line-height: 1.6;
  max-width: 320px;
}

/* difficulty */
.diff-heading {
  font-size: .72rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted2); margin-bottom: 10px;
}
.diff-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }

.diff-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--rsm);
  color: var(--muted2);
  font-family: var(--sans); font-size: .85rem; font-weight: 600;
  padding: 12px 6px 10px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: all var(--transition);
}
.diff-btn:hover { border-color: var(--border2); color: var(--text); transform: translateY(-1px); }

.diff-name { font-size: .88rem; }
.diff-info { font-size: .65rem; font-weight: 400; color: var(--muted); letter-spacing: .03em; }

.diff-btn.active[data-diff="easy"]   { border-color: var(--easy); color: var(--easy); background: rgba(0,230,118,.06); }
.diff-btn.active[data-diff="medium"] { border-color: var(--med);  color: var(--med);  background: rgba(0,176,255,.06); }
.diff-btn.active[data-diff="hard"]   { border-color: var(--hard); color: var(--hard); background: rgba(255,64,129,.06); }

/* start button */
.btn-start {
  background: var(--neon); color: var(--bg);
  border: none; border-radius: var(--r);
  font-family: var(--sans); font-size: 1.05rem; font-weight: 700;
  letter-spacing: .05em; padding: 16px 36px;
  cursor: pointer; align-self: flex-start;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 0 0 0 var(--neon-glow);
}
.btn-start:hover {
  opacity: .88; transform: translateY(-2px);
  box-shadow: 0 8px 32px var(--neon-glow);
}
.btn-start:active { transform: translateY(0); }

/* leaderboard */
.lb-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 18px;
}
.lb-header {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .8rem; font-weight: 600; color: var(--muted2); margin-bottom: 12px;
}
.lb-clear-btn {
  background: none; border: 1px solid var(--border2);
  border-radius: 6px; color: var(--muted2);
  font-size: .7rem; padding: 3px 10px; cursor: pointer;
  transition: all var(--transition);
}
.lb-clear-btn:hover { border-color: var(--hot); color: var(--hot); }

.lb-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }

.lb-entry {
  display: flex; align-items: center; gap: 10px;
  font-size: .82rem;
  animation: slideIn .2s ease;
}
.lb-rank { font-family: var(--mono); font-size: .7rem; color: var(--muted); width: 18px; }
.lb-rank.gold   { color: #ffd700; }
.lb-rank.silver { color: #c0c0c0; }
.lb-rank.bronze { color: #cd7f32; }

.lb-name { flex: 1; color: var(--text); font-weight: 500; }
.lb-score { font-family: var(--mono); font-size: .88rem; color: var(--neon); }
.lb-diff  { font-size: .65rem; color: var(--muted); }

.lb-empty { color: var(--muted); font-size: .82rem; text-align: center; padding: 8px 0; }

/* ── ══════════════════════════════
   GAME SCREEN
══════════════════════════════ ── */
#screen-game { align-items: flex-start; overflow-y: auto; padding: 16px 16px 60px; }

.game-wrap {
  width: 100%; max-width: 440px;
  margin: auto;
  display: flex; flex-direction: column; gap: 14px;
  padding-top: 8px;
}

/* topbar */
.topbar {
  display: flex; align-items: center; gap: 10px;
}
.btn-icon {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--rsm); color: var(--muted2);
  font-size: 1.05rem; width: 38px; height: 38px;
  cursor: pointer; display: grid; place-items: center;
  transition: all var(--transition); flex-shrink: 0;
}
.btn-icon:hover { border-color: var(--border2); color: var(--text); }

.topbar-scores { display: flex; gap: 6px; flex: 1; }

.mini-score {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--rsm); padding: 5px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  flex: 1;
}
.streak-chip { border-color: rgba(255,140,0,.35); }

.ms-label { font-size: 9px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted2); }
.ms-val   { font-family: var(--mono); font-size: .95rem; font-weight: 700; color: var(--text); }
.ms-val.pop { animation: scorePop .3s ease; }

.diff-badge {
  font-size: .7rem; font-weight: 600; letter-spacing: .06em;
  padding: 4px 11px; border-radius: 99px;
  border: 1px solid var(--border); color: var(--muted2);
  flex-shrink: 0; white-space: nowrap;
}
.diff-badge.easy   { border-color: var(--easy); color: var(--easy); background: rgba(0,230,118,.07); }
.diff-badge.medium { border-color: var(--med);  color: var(--med);  background: rgba(0,176,255,.07); }
.diff-badge.hard   { border-color: var(--hard); color: var(--hard); background: rgba(255,64,129,.07); }

/* dots */
.attempt-bar { display: flex; align-items: center; gap: 10px; }
.dots-row    { display: flex; gap: 5px; flex-wrap: wrap; flex: 1; }

.dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--border2);
  transition: background .25s, transform .2s, box-shadow .2s;
}
.dot.d-high { background: var(--hot);  transform: scale(1.1); }
.dot.d-low  { background: var(--cool); transform: scale(1.1); }
.dot.d-win  {
  background: var(--neon); transform: scale(1.3);
  box-shadow: 0 0 10px var(--neon-glow);
}
.tries-label { font-family: var(--mono); font-size: 11px; color: var(--muted2); white-space: nowrap; }

/* heat meter */
.heat-row {
  display: flex; align-items: center; gap: 8px;
}
.heat-end { font-size: .85rem; flex-shrink: 0; }
.heat-track {
  flex: 1; height: 7px; border-radius: 99px;
  background: linear-gradient(90deg, var(--cold), #9b79e0 50%, var(--hot));
  position: relative;
}
.heat-thumb {
  position: absolute; top: 50%; left: 50%;
  width: 17px; height: 17px; border-radius: 50%;
  background: var(--text); border: 2.5px solid var(--bg);
  transform: translate(-50%,-50%);
  transition: left .5s cubic-bezier(.4,0,.2,1), background .4s;
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.heat-word {
  font-size: .72rem; font-weight: 600; letter-spacing: .05em;
  color: var(--muted2); width: 64px; text-align: right; flex-shrink: 0;
  transition: color .3s;
}

/* range pill */
.range-pill {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 99px; padding: 7px 20px; align-self: center;
  font-family: var(--mono); font-size: .82rem;
}
.range-arrow { color: var(--neon); font-weight: 700; letter-spacing: .05em; transition: all .3s; }
.range-sep   { color: var(--muted); }

/* input */
.input-zone { display: flex; gap: 10px; }
.guess-input {
  flex: 1; background: var(--surface2); border: 1.5px solid var(--border2);
  border-radius: 12px; color: var(--text);
  font-family: var(--mono); font-size: 2.1rem; font-weight: 700;
  text-align: center; padding: 13px 10px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.guess-input::-webkit-outer-spin-button,
.guess-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.guess-input:focus {
  border-color: var(--neon);
  box-shadow: 0 0 0 3px var(--neon-dim);
}
.guess-input::placeholder { color: var(--muted); }
.guess-input:disabled { opacity: .3; }

.btn-guess {
  background: var(--neon); color: var(--bg);
  border: none; border-radius: 12px;
  font-family: var(--sans); font-size: .95rem; font-weight: 700;
  letter-spacing: .05em; padding: 13px 22px;
  cursor: pointer; white-space: nowrap;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
}
.btn-guess:hover  { opacity: .86; transform: translateY(-2px); box-shadow: 0 8px 28px var(--neon-glow); }
.btn-guess:active { transform: translateY(0); }
.btn-guess:disabled { opacity: .25; cursor: not-allowed; transform: none; box-shadow: none; }

/* feedback */
.feedback-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 13px 16px; min-height: 54px;
  transition: border-color .3s, background .3s;
}
.feedback-box.fb-high { border-color: var(--hot);  background: rgba(255,78,80,.06); }
.feedback-box.fb-low  { border-color: var(--cool); background: rgba(79,163,224,.06); }
.feedback-box.fb-win  { border-color: var(--neon); background: var(--neon-dim); }
.feedback-box.fb-lose { border-color: var(--hot);  background: rgba(255,78,80,.06); }

.fb-icon { font-size: 1.3rem; flex-shrink: 0; }
.fb-text { font-size: .87rem; line-height: 1.45; color: var(--muted2); transition: color .25s; }
.feedback-box.fb-high .fb-text { color: var(--hot);  }
.feedback-box.fb-low  .fb-text { color: var(--cool); }
.feedback-box.fb-win  .fb-text { color: var(--neon); font-weight: 600; }
.feedback-box.fb-lose .fb-text { color: var(--hot);  }

/* history */
.history-panel { display: flex; flex-direction: column; gap: 8px; }
.history-hdr {
  display: flex; justify-content: space-between;
  font-size: .72rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); padding: 0 2px;
}
.history-list {
  list-style: none; display: flex; flex-direction: column; gap: 5px;
  max-height: 145px; overflow-y: auto; padding-right: 2px;
}
.history-list::-webkit-scrollbar { width: 3px; }
.history-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

.hi {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px; border-radius: var(--rsm);
  background: var(--bg); border: 1px solid var(--border);
  font-family: var(--mono); font-size: .8rem;
  animation: slideIn .22s ease;
}
.hi-num  { font-size: 1rem; font-weight: 700; color: var(--text); min-width: 34px; }
.hi-bar  { flex: 1; height: 3px; border-radius: 99px; background: var(--border2); overflow: hidden; }
.hi-fill { height: 100%; border-radius: 99px; transition: width .4s; }
.hi-hint { font-size: .73rem; white-space: nowrap; min-width: 70px; text-align: right; }

.hi.hi-high .hi-hint { color: var(--hot);  }
.hi.hi-high .hi-fill { background: var(--hot); }
.hi.hi-low  .hi-hint { color: var(--cool); }
.hi.hi-low  .hi-fill { background: var(--cool); }
.hi.hi-win  { border-color: var(--neon); }
.hi.hi-win  .hi-hint { color: var(--neon); }
.hi.hi-win  .hi-fill { background: var(--neon); }

/* ── ══════════════════════════════
   MODALS  (Pause + End)
══════════════════════════════ ── */
.modal {
  background: var(--surface);
  border: 1.5px solid var(--border2);
  border-radius: 20px; padding: 40px 32px 32px;
  width: 100%; max-width: 360px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  animation: fadeUp .35s ease;
  text-align: center;
}

.modal-title { font-size: 1.5rem; font-weight: 700; }
.modal-sub   { color: var(--muted2); font-size: .9rem; }

.modal-actions {
  display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 6px;
}
.btn-modal-primary {
  background: var(--neon); color: var(--bg);
  border: none; border-radius: 12px;
  font-family: var(--sans); font-size: .95rem; font-weight: 700;
  letter-spacing: .05em; padding: 14px;
  cursor: pointer; width: 100%;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
}
.btn-modal-primary:hover { opacity: .87; transform: translateY(-1px); box-shadow: 0 6px 24px var(--neon-glow); }

.btn-modal-ghost {
  background: transparent; border: 1.5px solid var(--border2);
  border-radius: 12px; color: var(--muted2);
  font-family: var(--sans); font-size: .9rem; font-weight: 600;
  padding: 13px; cursor: pointer; width: 100%;
  transition: all var(--transition);
}
.btn-modal-ghost:hover { border-color: var(--text); color: var(--text); }

/* end modal extras */
.end-modal { max-width: 400px; }
.end-icon  { font-size: 3.4rem; line-height: 1; }

.end-title { font-size: 1.9rem; font-weight: 700; letter-spacing: -.03em; }
.end-title.win-t  { color: var(--neon); text-shadow: 0 0 30px var(--neon-glow); }
.end-title.lose-t { color: var(--hot); }

.end-msg { color: var(--muted2); font-size: .88rem; line-height: 1.6; max-width: 280px; }
.end-msg strong { color: var(--text); }

.end-stats {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 2px;
}
.stat-chip {
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--rsm); padding: 8px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.sc-label { font-size: .65rem; color: var(--muted2); text-transform: uppercase; letter-spacing: .08em; }
.sc-val   { font-family: var(--mono); font-size: 1.05rem; font-weight: 700; color: var(--text); }

/* ── ANIMATIONS ────────────────────────────────────────────── */
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes scorePop {
  0%   { transform: scale(1);    color: var(--text); }
  45%  { transform: scale(1.45); color: var(--neon); }
  100% { transform: scale(1);    color: var(--text); }
}
@keyframes shakeX {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-9px); }
  40%     { transform: translateX(9px); }
  60%     { transform: translateX(-5px); }
  80%     { transform: translateX(5px); }
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 var(--neon-glow); }
  50%     { box-shadow: 0 0 0 8px transparent; }
}

.shake  { animation: shakeX .35s ease; }
.pulse  { animation: pulse .6s ease; }

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 400px) {
  .guess-input  { font-size: 1.65rem; }
  .modal        { padding: 30px 20px 24px; }
  .diff-btn     { padding: 10px 4px 8px; }
  .diff-name    { font-size: .78rem; }
  .ms-val       { font-size: .85rem; }
}

@media (max-height: 600px) {
  .start-inner  { gap: 18px; }
  .start-title  { font-size: 2.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}