:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #d8dce3;
  --brand: #0066cc;
  --brand-soft: #eaf3ff;
  --green: #1d7f45;
  --red: #d70015;
  --shadow: 0 24px 70px rgb(17 24 39 / 14%);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgb(0 102 204 / 14%), transparent 30rem),
    linear-gradient(135deg, #f8fafc 0%, #f5f5f7 55%, #f3faf6 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.options button:disabled,
.tiles button:disabled,
.board button:disabled,
.lanes button:disabled {
  color: var(--text);
  -webkit-text-fill-color: currentColor;
  opacity: 0.84;
}

.options button:disabled span,
.tiles button:disabled span,
.board button:disabled span,
.lanes button:disabled span {
  color: var(--muted);
  -webkit-text-fill-color: currentColor;
}

.options button:disabled.selected,
.tiles button:disabled.selected,
.board button:disabled.selected,
.lanes button:disabled.selected {
  opacity: 0.95;
}

#app {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.hero,
.play,
.result,
.history {
  border: 1px solid rgb(216 220 227 / 78%);
  background: rgb(255 255 255 / 84%);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero {
  display: flex;
  min-height: 126px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-radius: 32px;
  padding: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(42px, 7vw, 84px);
  line-height: 0.95;
  letter-spacing: 0;
}

.meta {
  display: grid;
  min-width: min(420px, 100%);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.meta span {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-soft);
  padding: 12px 14px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.play {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
  gap: 20px;
  margin-top: 20px;
  border-radius: 34px;
  padding: 20px;
}

.prompt {
  display: grid;
  min-height: 520px;
  place-items: center;
  border-radius: 28px;
  background:
    linear-gradient(90deg, rgb(0 102 204 / 8%), transparent 38%),
    linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  padding: 36px;
  text-align: center;
}

.prompt > span {
  display: block;
  max-width: 520px;
  margin-top: 22px;
  color: var(--muted);
  font-size: 18px;
  font-weight: 650;
  line-height: 1.5;
}

.sequence-order {
  display: flex;
  max-width: 560px;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
}

.sequence-order span {
  display: grid;
  width: 86px;
  min-height: 104px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--surface);
}

.sequence-order strong {
  color: var(--brand);
  font-size: 42px;
  line-height: 1;
}

.sequence-order small {
  color: var(--muted);
  font-size: 16px;
  font-weight: 800;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface);
  padding: 18px;
}

.stake {
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.stake input {
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 18px;
  outline: none;
  padding: 0 16px;
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
}

.stake input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.board button {
  display: grid;
  aspect-ratio: 1;
  min-height: 94px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #f8fafc;
  color: var(--text);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.board button:not(:disabled):hover,
.board button.selected {
  border-color: var(--brand);
  background: var(--brand-soft);
  transform: translateY(-1px);
}

.board strong {
  font-size: 32px;
  line-height: 1;
}

.board span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.controls {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 10px;
}

.clear-button,
.tap-button {
  min-height: 62px;
  border: 0;
  border-radius: 22px;
  font-weight: 850;
  transition:
    transform 160ms ease,
    background 160ms ease;
}

.clear-button {
  background: var(--surface-soft);
  color: var(--muted);
}

.tap-button {
  background: var(--text);
  color: #fff;
}

.clear-button:not(:disabled):hover,
.tap-button:not(:disabled):hover {
  transform: translateY(-1px);
}

.tap-button:not(:disabled):hover {
  background: var(--brand);
}

.result {
  display: flex;
  min-height: 118px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 20px;
  border-radius: 30px;
  padding: 26px;
}

.result.win {
  border-color: rgb(29 127 69 / 24%);
  background: rgb(240 253 244 / 88%);
}

.result.lose {
  border-color: rgb(215 0 21 / 18%);
  background: rgb(255 245 246 / 88%);
}

.result strong {
  display: block;
  font-size: 24px;
}

.result span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.55;
}

.settlement {
  min-width: 150px;
  border-radius: 22px;
  background: var(--surface);
  padding: 18px;
}

.settlement span {
  margin: 0 0 6px;
  font-size: 13px;
}

.history {
  margin-top: 20px;
  border-radius: 30px;
  padding: 24px;
}

.history h2 {
  font-size: 30px;
}

.history ol {
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.history li,
.empty-history {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-soft);
  padding: 16px;
}

.history li {
  display: grid;
  grid-template-columns: 52px minmax(100px, 0.5fr) minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.history li span,
.history li small,
.empty-history {
  color: var(--muted);
}

.history li strong {
  font-size: 17px;
}

.history li small {
  font-size: 14px;
}

.error {
  margin-top: 16px;
  border-radius: 18px;
  background: #fff5f6;
  padding: 14px 16px;
  color: var(--red);
  font-weight: 750;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}

@media (max-width: 860px) {
  #app {
    width: min(100vw - 20px, 680px);
    padding: 20px 0;
  }

  .hero,
  .play,
  .result {
    border-radius: 24px;
  }

  .hero,
  .result {
    align-items: stretch;
    flex-direction: column;
  }

  .meta,
  .play {
    min-width: 0;
    grid-template-columns: 1fr;
  }

  .play {
    padding: 14px;
  }

  .prompt {
    min-height: 390px;
    padding: 22px;
  }

  .sequence-order span {
    width: 68px;
    min-height: 84px;
    border-radius: 22px;
  }

  .sequence-order strong {
    font-size: 32px;
  }

  .history li {
    grid-template-columns: 1fr;
  }
}

/* Mobile compact status strip */
@media (max-width: 560px) {
  .hero {
    min-height: 0;
    gap: 14px;
    padding: 20px;
  }

  .meta {
    width: 100%;
    min-width: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .meta span {
    min-height: 34px;
    display: flex;
    align-items: center;
    border-radius: 999px;
    padding: 7px 10px;
    font-size: 12px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
