* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: 'Segoe UI', Arial, sans-serif;
  user-select: none;
}

#back-home {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  color: #1c2b45;
  background: rgba(255,255,255,0.92);
  border-radius: 20px;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
#back-home:active { transform: translateY(1px); }

#game-wrap {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#game {
  max-width: 100vw;
  max-height: 100vh;
  max-height: 100dvh;
  background: #7ec8e3;
  display: block;
  touch-action: none;
}
/* portrait canvas is sized in JS to match the device aspect, so fill both
   dimensions for an exact full-screen fit with no black bars */
#game.portrait {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}
#game.landscape {
  width: 100vw;
  height: auto;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
  background: rgba(10, 20, 40, 0.78);
  padding: 20px;
  gap: 8px;
  overflow-y: auto;
}

.screen.hidden { display: none; }

.logo-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-bottom: 4px;
  padding: 10px 22px;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
}
.logo {
  height: 60px;
  width: auto;
}
.logo-gift { height: 66px; }

.tagline {
  font-size: clamp(12px, 2.4vw, 15px) !important;
  opacity: .9;
  max-width: 340px;
  margin: 0 0 4px !important;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 14px;
  margin: 2px 0 4px;
  font-size: 13px;
  font-weight: 700;
  color: #eafff0;
  background: rgba(16, 122, 63, .35);
  border: 1px solid rgba(120, 240, 170, .55);
  border-radius: 30px;
}
.live-badge.hidden { display: none; }
.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #35e07a;
  box-shadow: 0 0 0 0 rgba(53, 224, 122, .7);
  animation: livePulse 1.6s infinite;
}
@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(53, 224, 122, .7); }
  70% { box-shadow: 0 0 0 8px rgba(53, 224, 122, 0); }
  100% { box-shadow: 0 0 0 0 rgba(53, 224, 122, 0); }
}

.name-input {
  width: min(320px, 86vw);
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  color: #1c2b45;
  background: #fff;
  border: 2px solid #ffd93d;
  border-radius: 30px;
  outline: none;
  margin: 2px 0;
}
.name-input::placeholder { color: #8894a8; font-weight: 500; }
.name-input:focus { border-color: #ffb700; box-shadow: 0 0 0 3px rgba(255,183,0,.35); }

.leaderboard-card {
  width: min(320px, 86vw);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 16px;
  padding: 10px 14px;
  margin: 4px 0;
}
.leaderboard-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
}
.lb-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lb-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
}
.lb-list li:nth-child(1) { background: rgba(255,215,64,0.22); }
.lb-list li:nth-child(2) { background: rgba(200,200,210,0.18); }
.lb-list li:nth-child(3) { background: rgba(205,127,50,0.2); }
.lb-rank { width: 20px; font-weight: 800; text-align: center; }
.lb-name { flex: 1; text-align: left; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 800; color: #ffd93d; }
.lb-empty { justify-content: center; opacity: .7; font-style: italic; }

.settings-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(320px, 86vw);
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  margin: 4px 0;
}
.setting-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}
.setting-label {
  font-size: 13px;
  font-weight: 700;
  opacity: .95;
}
.setting-label b { color: #ffd93d; }

.start-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(280px, 78vw);
  margin-top: 4px;
}
.start-actions .btn { margin-top: 0; width: 100%; }

.note {
  font-size: 12px !important;
  opacity: .8;
  margin: 4px 0 0 !important;
}

.screen h1 {
  font-size: clamp(24px, 6vw, 38px);
  margin: 2px 0 2px;
  text-shadow: 0 3px 0 #00000055;
}

.screen h2 {
  font-size: clamp(20px, 5vw, 32px);
  margin: 0 0 6px;
}

.screen p {
  font-size: clamp(13px, 2.6vw, 16px);
  line-height: 1.5;
  max-width: 420px;
  margin: 0 0 8px;
}

.btn {
  font-size: clamp(13px, 2.6vw, 15px);
  font-weight: 700;
  padding: 10px 18px;
  border: none;
  border-radius: 40px;
  background: linear-gradient(180deg, #ffd93d, #ffb700);
  color: #402a00;
  cursor: pointer;
  box-shadow: 0 5px 0 #b57d00;
  margin-top: 8px;
  transition: transform .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #b57d00; }

.btn-secondary {
  background: linear-gradient(180deg, #6fd18a, #33a85c);
  color: #ffffff;
  box-shadow: 0 6px 0 #1f6e3c;
}
.btn-secondary:active { box-shadow: 0 2px 0 #1f6e3c; }

#orient-select {
  display: flex;
  gap: 10px;
  margin: 4px 0;
  justify-content: center;
}
.mode-btn {
  padding: 8px 18px;
  border: 2px solid rgba(255,255,255,.4);
  border-radius: 30px;
  background: rgba(255,255,255,.1);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all .12s;
}
.mode-btn.active {
  background: linear-gradient(180deg, #ffd93d, #ffb700);
  color: #402a00;
  border-color: #fff;
  box-shadow: 0 4px 12px rgba(255,183,0,.4);
}

#sensitivity {
  width: 100%;
  accent-color: #ffb700;
  cursor: pointer;
}
#sens-hint {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  opacity: .7;
  width: 100%;
}

.error {
  color: #ff8080;
  font-weight: 600;
  min-height: 20px;
}

.spinner {
  width: 46px;
  height: 46px;
  border: 5px solid rgba(255,255,255,.25);
  border-top-color: #ffd93d;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-top: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

#mic-status {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0,0,0,.8);
  background: rgba(0,0,0,.35);
  padding: 6px 12px;
  border-radius: 20px;
  z-index: 5;
}
#mic-status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #888;
  flex-shrink: 0;
}
#mic-status.listening #mic-status-dot {
  background: #4caf50;
  box-shadow: 0 0 8px #4caf50;
  animation: pulse-dot 1s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: .7; }
}

#mic-transcript {
  position: absolute;
  top: 46px;
  left: 12px;
  max-width: 260px;
  color: #fff;
  font-size: 12px;
  font-style: italic;
  text-shadow: 0 1px 3px rgba(0,0,0,.8);
  background: rgba(0,0,0,.35);
  padding: 4px 10px;
  border-radius: 12px;
  z-index: 5;
  min-height: 16px;
}

#hud {
  position: absolute;
  top: 10px;
  right: 12px;
  color: #fff;
  text-align: right;
  text-shadow: 0 2px 4px rgba(0,0,0,.6);
  z-index: 5;
}
#hud.hidden { display: none; }
#score { font-size: 40px; font-weight: 800; line-height: 1; }
#best { font-size: 13px; opacity: .9; }
