:root {
  --bg: #0b0f1c;
  --surface: #141a2c;
  --surface-2: #1c2438;
  --border: #2a334d;
  --text: #e8eaf0;
  --text-muted: #8a93ad;
  --accent: #378add;
  --accent-bg: #12233a;
  --success: #9fe1cb;
  --danger: #f09595;
  --gold: #fac775;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;                 /* sem scroll de página; bloqueia pull-to-refresh */
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;   /* iOS não reescala o texto */
  touch-action: manipulation;       /* bloqueia double-tap zoom; mantém taps/scroll interno */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding:
    calc(4px + env(safe-area-inset-top))
    calc(4px + env(safe-area-inset-right))
    calc(4px + env(safe-area-inset-bottom))
    calc(4px + env(safe-area-inset-left));
}

.game-card {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.canvas-wrap { position: relative; }

canvas#game {
  width: 100%;
  display: block;
  border-radius: 0;
  background: var(--bg);
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 15, 28, 0.78);
  border-radius: var(--radius);
}
.overlay[hidden] { display: none; }

.panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  width: 84%;
  max-width: 290px;
  text-align: center;
}

.panel h2 { font-size: 18px; font-weight: 500; margin: 0 0 4px; }
.panel .record { font-size: 12px; color: var(--success); font-weight: 500; margin: 0 0 10px; }
.panel .score-row { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 14px; }
.panel .medal {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; flex-shrink: 0;
}
.panel .score-label { font-size: 12px; color: var(--text-muted); margin: 0; }
.panel .score-value { font-size: 26px; font-weight: 500; margin: 0; }
.panel .score-sub { font-size: 12px; color: var(--text-muted); margin: 4px 0 0; }
.panel .btn-col { display: flex; flex-direction: column; gap: 8px; }
.panel .rank-list { max-height: 190px; overflow-y: auto; margin-bottom: 12px; }
.panel .rank-row {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.panel .rank-row.me { color: var(--accent); font-weight: 500; }
.panel .rank-pos { min-width: 18px; color: var(--text-muted); }
.panel .rank-name { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel .rank-lvl { color: var(--text-muted); }
.panel .rank-pts { min-width: 56px; text-align: right; }
.panel .note { font-size: 11px; color: var(--text-muted); margin: 8px 0 0; }
.panel input[type="text"] {
  width: 100%; height: 36px; margin-bottom: 10px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 0 10px; font-size: 14px;
}
.panel input[type="text"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.panel input[type="text"] { user-select: text; -webkit-user-select: text; }

button {
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
button:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: var(--accent);
  height: 44px;
}
.btn-half { flex: 1; height: 40px; font-size: 13px; }

@media (min-width: 700px) {
  .app { height: auto; min-height: 100dvh; justify-content: center; }
}

.overlay { z-index: 4; }               /* painel de fim de jogo acima da camada de toque e do som */
.touch-layer { position: absolute; inset: 0; z-index: 2; touch-action: none; }
.mute-btn {
  position: absolute;
  top: calc(6px + env(safe-area-inset-top));
  right: calc(6px + env(safe-area-inset-right));
  z-index: 3;
  width: 34px; height: 34px; padding: 0;
  font-size: 16px; text-align: center;
  background: rgba(20, 26, 44, 0.45);
  border: 0; border-radius: 8px;
  color: var(--text); opacity: 0.7;
}
.touch-layer .tz {
  position: absolute; display: flex; align-items: center; justify-content: center;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.tz-left  { top: 0; left: 0;  width: 50%; bottom: var(--motor-h, 22%); }
.tz-right { top: 0; right: 0; width: 50%; bottom: var(--motor-h, 22%); }
.tz-motor { left: 0; right: 0; bottom: 0; height: var(--motor-h, 22%); }
.tz-hint { color: var(--text); opacity: 0.16; pointer-events: none; transition: opacity .1s; }
.tz-left .tz-hint, .tz-right .tz-hint { font-size: 40px; }
.tz-motor .tz-hint { font-size: 15px; letter-spacing: 1px; }
.tz.active { background: rgba(255,255,255,0.05); }
.tz.active .tz-hint { opacity: 0.42; }
@media (hover: hover) { .tz-hint { opacity: 0.09; } }   /* desktop: mais discreto */
