:root {
  color-scheme: light;
  --bg: #f6f8fc;
  --panel: #ffffff;
  --panel-2: #eef3fb;
  --text: #172033;
  --muted: #657188;
  --line: #d7deeb;
  --primary: #2563eb;
  --primary-ink: #ffffff;
  --accent: #f59e0b;
  --accent-soft: #fff4d7;
  --danger: #e11d48;
  --shadow: 0 14px 34px rgba(37, 99, 235, 0.12);
  --button-shadow: 0 14px 28px rgba(37, 99, 235, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.08), transparent 18rem),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 48%, #eef2f8 100%);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: min(100%, 520px);
  min-height: 100svh;
  margin: 0 auto;
  padding: 20px 16px 28px;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
}

.brand {
  font-weight: 800;
  letter-spacing: 0;
  font-size: 1rem;
  color: var(--primary);
}

.step {
  color: var(--muted);
  font-size: 0.88rem;
  flex: 0 0 auto;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 9vw, 3.1rem);
  line-height: 1.05;
  letter-spacing: 0;
  color: #101827;
}

h2 {
  font-size: 1.55rem;
  line-height: 1.2;
}

.lead {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.form-grid {
  display: grid;
  gap: 14px;
}

.how-to {
  display: grid;
  gap: 18px;
}

.how-to h2 {
  margin-bottom: 8px;
  font-size: 1.15rem;
}

.rule-list {
  margin: 0;
  padding-left: 1.4rem;
  color: var(--muted);
  line-height: 1.65;
}

.rule-list li + li {
  margin-top: 6px;
}

.home-hero {
  display: grid;
  gap: 10px;
  justify-items: center;
  text-align: center;
  padding: 2px 0 8px;
}

.home-logo {
  width: min(76vw, 360px);
  aspect-ratio: 1;
  object-fit: contain;
}

.eyebrow {
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 850;
}

.game-list {
  display: grid;
  gap: 12px;
}

.game-card {
  display: grid;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.game-card.disabled {
  opacity: 0.72;
}

.game-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-bottom: 10px;
  padding: 0 10px;
  border-radius: 999px;
  color: #92400e;
  background: var(--accent-soft);
  font-size: 0.82rem;
  font-weight: 850;
}

.field {
  display: grid;
  gap: 8px;
}

.field label,
.label {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
}

.number-row {
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  gap: 10px;
}

.count {
  text-align: center;
  font-size: 1.8rem;
  font-weight: 850;
}

.icon-btn,
.primary,
.secondary,
.ghost,
.danger {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  min-height: 52px;
  font-weight: 800;
}

.icon-btn {
  min-height: 50px;
  font-size: 1.45rem;
  color: var(--primary);
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.primary {
  width: 100%;
  color: var(--primary-ink);
  background: var(--primary);
  border: 2px solid #1749b7;
  box-shadow: var(--button-shadow);
  position: relative;
}

.primary::after,
.hold-btn::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  pointer-events: none;
}

.secondary {
  width: 100%;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(23, 32, 51, 0.06);
}

.ghost {
  min-height: 44px;
  color: var(--muted);
  background: transparent;
  padding: 0 8px;
}

.danger {
  width: 100%;
  color: #ffffff;
  background: var(--danger);
}

.primary:disabled,
.secondary:disabled,
.icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.names {
  display: grid;
  gap: 10px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segment {
  min-height: 48px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--text);
  background: #ffffff;
  font-weight: 800;
}

.segment.active {
  color: var(--primary-ink);
  border-color: var(--primary);
  background: var(--primary);
}

.spacer {
  flex: 1;
}

.handoff {
  display: grid;
  gap: 16px;
  text-align: center;
  padding-top: 8px;
}

.player-name {
  color: #111827;
  font-size: clamp(2.1rem, 11vw, 3.4rem);
  line-height: 1.05;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.runoff-list {
  display: grid;
  gap: 8px;
  width: 100%;
}

.runoff-name {
  color: #111827;
  font-size: clamp(1.7rem, 8vw, 2.6rem);
  line-height: 1.14;
  font-weight: 900;
  overflow-wrap: anywhere;
  text-align: center;
}

.secret-box {
  min-height: 168px;
  display: grid;
  place-items: center;
  text-align: center;
  background: #ffffff;
  border: 2px dashed #c7d2e5;
  border-radius: 8px;
  padding: 18px;
  user-select: none;
  touch-action: none;
}

.secret-word {
  font-size: clamp(2.3rem, 13vw, 4.3rem);
  font-weight: 950;
  color: #111827;
  overflow-wrap: anywhere;
}

.masked {
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.6;
}

.hold-btn {
  min-height: 82px;
  width: 100%;
  border: 0;
  border-radius: 8px;
  color: var(--primary-ink);
  background: var(--primary);
  border: 2px solid #1749b7;
  box-shadow: var(--button-shadow);
  font-size: 1.15rem;
  font-weight: 900;
  touch-action: none;
  position: relative;
}

.timer-wrap {
  display: grid;
  gap: 18px;
  text-align: center;
  margin-top: 8px;
}

.timer {
  font-variant-numeric: tabular-nums;
  font-size: clamp(4.8rem, 27vw, 8rem);
  line-height: 1;
  font-weight: 950;
}

.timer.conversation {
  color: var(--primary);
}

.timer.discussion {
  color: var(--accent);
}

.timer-adjust {
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  gap: 10px;
}

.timer-adjust-label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.choice-list {
  display: grid;
  gap: 10px;
}

.choice {
  width: 100%;
  min-height: 58px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--text);
  background: #ffffff;
  font-weight: 850;
  box-shadow: 0 8px 18px rgba(23, 32, 51, 0.05);
}

.choice.selected {
  color: #111827;
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}

.reveal-stage {
  min-height: 220px;
  display: grid;
  place-items: center;
  text-align: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.dramatic {
  color: var(--muted);
  font-size: 1.15rem;
}

.wolf-name {
  color: var(--danger);
  font-size: clamp(2.4rem, 13vw, 4.4rem);
  line-height: 1.08;
  font-weight: 950;
  overflow-wrap: anywhere;
  animation: pop 480ms ease both;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.stat {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.stat span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.stat strong {
  font-size: 1.18rem;
  overflow-wrap: anywhere;
}

.win {
  color: #0f766e;
}

.lose {
  color: var(--accent);
}

.late-janken-screen {
  gap: 18px;
}

.late-janken-title {
  display: grid;
  gap: 10px;
}

.late-janken-play {
  min-height: calc(100svh - 48px);
  display: grid;
  grid-template-rows: minmax(150px, 1fr) auto minmax(150px, 1fr);
  gap: 12px;
}

.late-player {
  display: grid;
  align-content: center;
  gap: 10px;
}

.late-player.flipped {
  transform: rotate(180deg);
}

.late-player-name {
  color: var(--muted);
  text-align: center;
  font-weight: 850;
}

.waiting-player {
  opacity: 0.92;
}

.waiting-hands {
  min-height: 92px;
  display: grid;
  place-items: center;
  border: 1px dashed #c7d2e5;
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-weight: 850;
  text-align: center;
}

.late-hand-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.hand-choice {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 8px 18px rgba(23, 32, 51, 0.06);
  display: grid;
  place-items: center;
  gap: 4px;
  font-weight: 900;
}

.hand-choice span {
  font-size: 2.1rem;
  line-height: 1;
}

.hand-choice strong {
  font-size: 0.95rem;
}

.late-janken-center {
  display: grid;
  gap: 10px;
}

.late-score-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 850;
}

.command-card {
  display: grid;
  place-items: center;
  gap: 8px;
  grid-template-rows: 2rem 3.2rem 6.8rem 1.4rem 3.2rem 2rem;
  min-height: 300px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  text-align: center;
}

.stable-slot {
  min-width: 0;
  overflow-wrap: anywhere;
}

.hidden-slot {
  visibility: hidden;
}

.ready-label,
.pon-label {
  color: var(--muted);
  font-size: clamp(1.2rem, 6vw, 2rem);
  font-weight: 900;
}

.pon-label {
  color: var(--accent);
}

.ready-fist {
  font-size: clamp(4.2rem, 21vw, 6.8rem);
  line-height: 1;
}

.command-label {
  color: var(--primary);
  font-size: clamp(1.8rem, 9vw, 3.2rem);
  line-height: 1.05;
  font-weight: 950;
}

.flipped-command {
  transform: rotate(180deg);
}

.center-hand {
  font-size: clamp(4.2rem, 21vw, 6.8rem);
  line-height: 1;
}

.center-hand-label {
  color: var(--muted);
  font-weight: 850;
}

.late-winner {
  color: var(--primary);
}

.round-result-stage {
  min-height: 360px;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.final-result-stage {
  min-height: 380px;
}

.player-result {
  display: grid;
  gap: 6px;
  text-align: center;
}

.player-result-name {
  color: var(--muted);
  font-weight: 850;
}

.player-result-text {
  font-size: clamp(2.5rem, 13vw, 4.8rem);
  line-height: 1;
  font-weight: 950;
}

.round-result-info {
  display: grid;
  gap: 4px;
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
  font-weight: 800;
}

.round-result-info strong {
  color: var(--text);
  font-size: 1rem;
  overflow-wrap: anywhere;
}

@keyframes pop {
  0% {
    opacity: 0;
    transform: scale(0.88);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@media (min-width: 480px) {
  .app {
    padding-top: 28px;
  }

  .panel {
    padding: 20px;
  }
}
