: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;
  --gold: #b7791f;
  --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 left, rgb(0 102 204 / 12%), transparent 32rem),
    linear-gradient(135deg, #f8fafc 0%, #f5f5f7 52%, #eef8f2 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

#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 / 82%);
  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.5fr) minmax(280px, 0.5fr);
  gap: 20px;
  margin-top: 20px;
  border-radius: 34px;
  padding: 20px;
}

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

.target-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 28px;
  background: #fff;
  padding: 24px;
  box-shadow: 0 18px 40px rgb(17 24 39 / 9%);
}

.target-card strong {
  display: block;
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1;
}

.target-card span {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: 17px;
  font-weight: 650;
}

.line-meter {
  position: relative;
  height: 170px;
  border: 1px solid var(--line);
  border-radius: 38px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgb(29 29 31 / 6%) 1px, transparent 1px) 0 0 / 10% 100%,
    linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
}

.baseline {
  position: absolute;
  right: 28px;
  bottom: 38px;
  left: 28px;
  height: 10px;
  border-radius: 999px;
  background: #d9dee7;
}

.zone {
  position: absolute;
  bottom: 30px;
  left: var(--start);
  width: var(--width);
  height: 26px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--zone) 36%, white);
}

.zone.target {
  bottom: 26px;
  height: 34px;
  background: var(--zone);
  box-shadow: 0 14px 34px color-mix(in srgb, var(--zone) 35%, transparent);
}

.marker {
  position: absolute;
  bottom: 18px;
  left: clamp(18px, var(--x), calc(100% - 18px));
  z-index: 2;
  width: 7px;
  height: 116px;
  border-radius: 999px;
  background: #1d1d1f;
  box-shadow: 0 18px 34px rgb(29 29 31 / 28%);
  transform: translateX(-50%);
}

.marker::before {
  position: absolute;
  top: -14px;
  left: 50%;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand);
  content: "";
  transform: translateX(-50%);
}

.marker.active::before {
  animation: pulse 1.1s ease-in-out infinite;
}

.scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.scale span:nth-child(2),
.scale span:nth-child(3),
.scale span:nth-child(4) {
  text-align: center;
}

.scale span:last-child {
  text-align: right;
}

.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);
}

.hint {
  min-height: 178px;
  border-radius: 24px;
  background: #f8fafc;
  padding: 22px;
}

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

.hint strong {
  display: block;
  margin-top: 8px;
  font-size: 40px;
  line-height: 1;
}

.hint p {
  margin-top: 16px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.stop-button {
  min-height: 62px;
  border: 0;
  border-radius: 22px;
  background: var(--text);
  color: #fff;
  font-weight: 850;
  transition:
    transform 160ms ease,
    background 160ms ease;
}

.stop-button:not(:disabled):hover {
  background: var(--brand);
  transform: translateY(-1px);
}

.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.near {
  border-color: rgb(183 121 31 / 28%);
  background: rgb(255 251 235 / 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: 160px;
  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;
}

@keyframes pulse {
  0%,
  100% {
    transform: translateX(-50%) scale(1);
  }
  50% {
    transform: translateX(-50%) scale(1.16);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    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 {
    min-width: 0;
  }

  .play {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .stage {
    min-height: 430px;
    padding: 20px;
  }

  .target-card strong {
    font-size: 38px;
  }

  .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;
  }
}
