/* Explosive Seconds — mobile-first party game theme */

:root {
  --bg: #0d1018;
  --bg-raised: #1a1f2a;
  --bg-sunken: #070910;
  --text: #f3f0ff;
  --text-muted: #a7afc4;
  --accent: #ff5c39;
  --accent-2: #ffb02e;
  --teal: #29c7c7;
  --success: #34d17b;
  --danger: #ff4757;
  --fuse-ok: #34d17b;
  --fuse-warn: #ffb02e;
  --fuse-crit: #ff4757;
  --radius: 8px;
  --control-radius: 12px;
  --shadow: 0 16px 36px rgba(0, 0, 0, 0.42);
  --line: rgba(255, 255, 255, 0.1);
}

* { box-sizing: border-box; }

/* Author display rules (flex on screens/cards) must never beat the hidden attribute. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100%;
}

body {
  display: flex;
  justify-content: center;
  background:
    radial-gradient(circle at 50% -20%, rgba(255, 176, 46, 0.16), transparent 36rem),
    linear-gradient(145deg, #111522 0%, var(--bg) 55%, #101417 100%);
  -webkit-tap-highlight-color: transparent;
}

.screen {
  width: min(100vw, 560px);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 16px;
}

#screen-home {
  background:
    linear-gradient(180deg, rgba(13, 16, 24, 0.45) 0%, rgba(13, 16, 24, 0.92) 85%),
    url('../assets/explosive-seconds-hero-generated.png') center top / cover no-repeat;
}

h1, h2, h3 { margin: 0; }
h3 {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  line-height: 1.35;
  margin-bottom: 10px;
}

.muted { color: var(--text-muted); font-weight: normal; font-size: 0.85em; }
.error-text { color: var(--danger); font-size: 0.9rem; margin: 8px 0 0; }

/* ---------- buttons ---------- */
.btn {
  border: 0;
  border-radius: var(--control-radius);
  font: inherit;
  font-weight: 700;
  color: var(--text);
  background: var(--bg-raised);
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.15s ease, box-shadow 0.15s ease;
  touch-action: manipulation;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--accent), #ff8a2e); box-shadow: 0 14px 28px rgba(255, 92, 57, 0.25); }
.btn-secondary { background: #202838; border: 1px solid var(--line); }
.btn-success { background: linear-gradient(135deg, #22b566, var(--success)); box-shadow: var(--shadow); }
.btn-danger { background: linear-gradient(135deg, #e03131, var(--danger)); box-shadow: var(--shadow); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-big { font-size: 1.15rem; padding: 16px 22px; }
.btn-small { font-size: 0.85rem; padding: 8px 12px; }

/* ---------- home ---------- */
.home-hero {
  flex: 1;
  display: grid;
  align-content: center;
  gap: 14px;
  text-align: center;
}
.home-copy {
  display: grid;
  gap: 10px;
  justify-items: center;
}
.home-hero h1 {
  font-size: clamp(2.35rem, 10vw, 3.35rem);
  line-height: 1.02;
  text-wrap: balance;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.55);
}
.tagline { color: var(--text-muted); max-width: 35ch; margin: 0; line-height: 1.45; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6); }
.home-actions { display: flex; flex-direction: column; gap: 12px; }
.join-row { display: flex; gap: 10px; }
.join-row input {
  flex: 1;
  min-width: 0;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  color: var(--text);
  font: inherit;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.35em;
  text-align: center;
  text-transform: uppercase;
  padding: 12px;
}
.home-footer { text-align: center; color: var(--text-muted); font-size: 0.8rem; padding-bottom: 8px; }

@media (max-height: 720px) {
  .screen { gap: 12px; }
  .home-hero h1 { font-size: clamp(2.15rem, 8vw, 3rem); }
  .tagline { font-size: 0.95rem; }
}

/* ---------- lobby ---------- */
.lobby-header { display: flex; align-items: center; gap: 8px; }
.lobby-header h2 { font-size: 1.3rem; }
.lobby-body { flex: 1; display: flex; flex-direction: column; gap: 14px; }
.panel {
  background: rgba(26, 31, 42, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.team-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.team-row { display: flex; gap: 8px; align-items: center; }
.team-row input[type="text"] {
  flex: 1;
  min-width: 0;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  padding: 10px;
}
.member-stepper { display: flex; align-items: center; gap: 6px; background: var(--bg-sunken); border-radius: 10px; padding: 4px 6px; }
.member-stepper button { background: none; border: 0; color: var(--accent-2); font-size: 1.1rem; font-weight: 800; cursor: pointer; padding: 2px 6px; }
.member-stepper .count { min-width: 3.2ch; text-align: center; font-size: 0.8rem; color: var(--text-muted); }
.team-remove { background: none; border: 0; color: var(--text-muted); font-size: 1.1rem; cursor: pointer; padding: 4px; }

.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chip {
  border: 1px solid var(--line);
  background: var(--bg-sunken);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-width: 0;
  text-align: left;
}
.chip span,
.chip {
  overflow-wrap: anywhere;
}
.chip.selected { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.chip .chip-x { opacity: 0.7; margin-left: 2px; }

.setting-row { display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
.setting-row span { display: flex; justify-content: space-between; }
.setting-row select {
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  padding: 10px;
}
input[type="range"] { accent-color: var(--accent); width: 100%; }

.room-code-label { margin: 0; color: var(--text-muted); font-size: 0.9rem; }
.checkbox-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
}
.checkbox-row input { margin-top: 3px; accent-color: var(--accent); flex-shrink: 0; }
.room-code {
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: 0.35em;
  text-align: center;
  margin: 8px 0;
  color: var(--accent-2);
}

.lobby-footer { position: sticky; bottom: 0; padding: 10px 0 6px; background: linear-gradient(transparent, var(--bg) 30%); display: flex; flex-direction: column; gap: 8px; }
.lobby-footer .btn { width: 100%; }

/* ---------- game ---------- */
.game-header { display: flex; justify-content: space-between; }
.pill {
  background: rgba(26, 31, 42, 0.9);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

.fuse-wrap { text-align: center; }
.fuse-seconds {
  font-size: clamp(4rem, 22vw, 6.5rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--fuse-ok);
  transition: color 0.3s ease;
}
.fuse-track {
  position: relative;
  height: 16px;
  background: #05070d;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 10px;
}
.fuse-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--fuse-ok), #8be35d);
  border-radius: 999px;
  box-shadow: 0 0 18px currentColor;
  transition: background 0.3s ease;
}
.fuse-spark {
  position: absolute;
  top: 50%;
  left: 100%;
  width: 28px;
  height: 28px;
  object-fit: contain;
  transform: translate(-50%, -50%);
  transition: left 0.3s linear;
  animation: spark-pulse 0.5s ease-in-out infinite;
  filter: drop-shadow(0 0 6px var(--fuse-ok));
  pointer-events: none;
}
@keyframes spark-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.3); }
}
.fuse-warn .fuse-seconds { color: var(--fuse-warn); }
.fuse-warn .fuse-bar { background: var(--fuse-warn); }
.fuse-warn .fuse-spark { filter: drop-shadow(0 0 8px var(--fuse-warn)); animation-duration: 0.35s; }
.fuse-crit .fuse-seconds { color: var(--fuse-crit); animation: pulse 0.5s ease-in-out infinite; }
.fuse-crit .fuse-bar { background: var(--fuse-crit); }
.fuse-crit .fuse-spark { filter: drop-shadow(0 0 10px var(--fuse-crit)); animation-duration: 0.18s; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }

.active-team {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 800;
  background: linear-gradient(135deg, rgba(255, 92, 57, 0.24), rgba(41, 199, 199, 0.14));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  overflow-wrap: anywhere;
}

.word-card {
  background: rgba(26, 31, 42, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 18px;
  text-align: center;
  box-shadow: var(--shadow);
}
.word-label { margin: 0 0 8px; color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; }
.word { margin: 0; font-size: clamp(1.8rem, 9vw, 2.6rem); font-weight: 900; line-height: 1.15; overflow-wrap: anywhere; }
.ready-text { font-size: 1.2rem; line-height: 1.35; margin: 0 0 18px; overflow-wrap: anywhere; }
.match-art {
  width: 100%;
  max-width: 220px;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 18px;
  margin: 0 auto 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

.play-actions { display: flex; gap: 12px; margin-top: 14px; }
.play-actions .btn { flex: 1; }
.skip-count { display: block; font-size: 0.75rem; font-weight: 600; color: var(--text-muted); }

#game-playing { display: flex; flex-direction: column; }
#game-ready { display: flex; flex-direction: column; gap: 4px; }

.team-status { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.team-status .team-line {
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(26, 31, 42, 0.9); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; font-size: 0.9rem;
}
.team-line.active-now { outline: 2px solid var(--accent); }
.team-line.dead { opacity: 0.4; text-decoration: line-through; }
.team-line .hearts { letter-spacing: 2px; }
.team-line .score { color: var(--accent-2); font-weight: 800; min-width: 3ch; text-align: right; }

/* ---------- boom ---------- */
.boom-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: radial-gradient(circle at 50% 40%, #4d1206, #12101c 75%);
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center; gap: 10px; padding: 24px;
}
.boom-overlay[hidden] { display: none; }
.boom-image {
  width: min(260px, 60vw);
  filter: drop-shadow(0 0 40px rgba(255, 71, 87, 0.55));
  animation: boom-in 0.45s cubic-bezier(0.2, 2.2, 0.4, 1);
}
@keyframes boom-in { from { transform: scale(0.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.boom-overlay h2 { font-size: 1.8rem; }
.boom-overlay p { color: var(--text-muted); }

/* ---------- game over ---------- */
.final-scores { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 360px; }
.final-scores .team-line {
  display: flex; justify-content: space-between;
  background: var(--bg-raised); border-radius: var(--radius); padding: 10px 14px;
}

/* ---------- dialog ---------- */
dialog {
  background: var(--bg-raised);
  color: var(--text);
  border: 0;
  border-radius: var(--control-radius);
  padding: 20px;
  width: min(92vw, 420px);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog label { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; font-size: 0.9rem; }
dialog input, dialog textarea {
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  padding: 10px;
  resize: vertical;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

#dialog-how-to-play {
  padding: 0;
  max-height: 85vh;
  overflow: hidden; /* only .htp-body scrolls */
}
.htp-body {
  padding: 20px;
  overflow-y: auto;
  max-height: 85vh;
  box-sizing: border-box;
}
.htp-body h2 { margin-bottom: 1rem; }
.htp-steps {
  padding-left: 1.2rem;
  margin: 0 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  line-height: 1.4;
}
.htp-note { font-size: 0.85rem; margin-bottom: 1rem; }
