* {
  box-sizing: border-box;
}

:root {
  font-family: Arial, Helvetica, sans-serif;
  color: #f6f7fb;
  background: #11141b;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top, rgba(76, 111, 255, 0.18), transparent 34rem),
    #11141b;
}

button,
select {
  font: inherit;
}

button,
select,
.play-area {
  -webkit-tap-highlight-color: transparent;
}

.page-shell {
  width: min(100% - 24px, 900px);
  margin: 0 auto;
  padding: 32px 0;
}

.game-card {
  background: #1a1f2a;
  border: 1px solid #2f3747;
  border-radius: 24px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.game-header,
.controls,
.instructions,
.result-card,
.leaderboard-section,
.round-strip {
  padding-left: clamp(20px, 4vw, 40px);
  padding-right: clamp(20px, 4vw, 40px);
}

.game-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  padding-top: 32px;
  padding-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #8ca0ff;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 7vw, 3.5rem);
  line-height: 1;
}

.subtitle {
  margin-bottom: 0;
  color: #b9c0ce;
  max-width: 560px;
  line-height: 1.5;
}

.best-panel {
  min-width: 190px;
  padding: 14px 16px;
  border-radius: 16px;
  background: #222a38;
  text-align: right;
}

.best-panel span,
.result-card span {
  display: block;
  color: #9ea8ba;
  font-size: 0.82rem;
  margin-bottom: 5px;
}

.best-panel strong,
.result-card strong {
  font-size: 1.45rem;
}

.controls {
  display: grid;
  grid-template-columns: auto minmax(130px, 180px) 1fr;
  gap: 12px;
  align-items: center;
  padding-top: 18px;
  padding-bottom: 18px;
  background: #151922;
  border-top: 1px solid #2b3342;
  border-bottom: 1px solid #2b3342;
}

.controls label {
  font-weight: 700;
}

select,
.primary-button,
.reaction-button {
  border: 0;
  border-radius: 12px;
  min-height: 46px;
}

select {
  width: 100%;
  padding: 0 12px;
  color: #f6f7fb;
  background: #293244;
  border: 1px solid #3a455a;
}

.primary-button {
  justify-self: end;
  padding: 0 22px;
  font-weight: 800;
  color: #11141b;
  background: #8ca0ff;
  cursor: pointer;
}

.primary-button:hover {
  filter: brightness(1.06);
}

.primary-button:focus-visible,
.reaction-button:focus-visible,
select:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

.round-strip {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding-top: 12px;
  padding-bottom: 12px;
  background: #1d2330;
  color: #c7cedc;
  font-weight: 700;
  font-size: 0.92rem;
}

.play-area {
  position: relative;
  min-height: 430px;
  overflow: hidden;
  padding: 34px 20px;
  text-align: center;
  transition: background-color 120ms ease;
  user-select: none;
}

.play-content {
  width: min(100%, 600px);
  margin: 0 auto;
  pointer-events: none;
}

.status-label {
  margin-bottom: 8px;
  color: #c7cedc;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
}

#status-message {
  margin-bottom: 10px;
  font-size: clamp(1.65rem, 5vw, 2.65rem);
}

#status-detail {
  color: #c6cbd6;
  line-height: 1.5;
  margin-bottom: 0;
}

.play-area.idle {
  background: #202735;
}

.play-area.waiting {
  background: #b64545;
}

.play-area.waiting .status-label,
.play-area.waiting #status-detail {
  color: #ffe6e6;
}

.play-area.go {
  background: #1f9d61;
}

.play-area.go .status-label,
.play-area.go #status-detail {
  color: #e7fff2;
}

.play-area.ended,
.play-area.round-complete {
  background: #2c3443;
}

.reaction-button {
  position: absolute;
  width: 150px;
  min-height: 58px;
  padding: 0 20px;
  font-size: 1.1rem;
  font-weight: 900;
  color: #101318;
  background: #ffffff;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
  transform: translate(-50%, -50%);
  left: 50%;
  top: 72%;
}

.reaction-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

.instructions {
  padding-top: 28px;
  padding-bottom: 8px;
}

.instructions h2,
.leaderboard-section h2 {
  font-size: 1.15rem;
  margin-bottom: 10px;
}

.instructions p {
  color: #b9c0ce;
  line-height: 1.6;
  margin-bottom: 0;
}

.result-card {
  display: flex;
  align-items: center;
  gap: 24px;
  justify-content: space-between;
  margin: 24px clamp(20px, 4vw, 40px) 0;
  padding-top: 18px;
  padding-bottom: 18px;
  background: #222a38;
  border-radius: 16px;
}

.result-card p {
  margin: 0;
  color: #c7cedc;
  text-align: right;
}

.leaderboard-section {
  padding-top: 30px;
  padding-bottom: 38px;
}

#mis-leaderboard:empty::before {
  content: "Leaderboard will appear here when the MIS Helper service is available.";
  display: block;
  color: #8f99aa;
  padding: 16px;
  border: 1px dashed #465065;
  border-radius: 12px;
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 16px, 900px);
    padding: 12px 0;
  }

  .game-card {
    border-radius: 18px;
  }

  .game-header {
    flex-direction: column;
  }

  .best-panel {
    width: 100%;
    text-align: left;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .primary-button {
    width: 100%;
    justify-self: stretch;
  }

  .round-strip {
    flex-direction: column;
    gap: 6px;
  }

  .play-area {
    min-height: 420px;
  }

  .reaction-button {
    width: 130px;
    min-height: 54px;
  }

  .result-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .result-card p {
    text-align: left;
  }
}
