:root {
  color-scheme: dark;
  --bg: #07080d;
  --panel: rgba(19, 13, 22, 0.84);
  --panel-strong: rgba(30, 17, 34, 0.94);
  --line: rgba(255, 210, 122, 0.28);
  --line-hot: rgba(82, 223, 255, 0.44);
  --text: #fff7e6;
  --muted: #d7b9c8;
  --amber: #ffc65a;
  --pink: #ff3c9d;
  --cyan: #52dfff;
  --green: #56f0a0;
  --danger: #ff5a68;
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  min-height: 100%;
  margin: 0;
  overscroll-behavior: none;
}

body {
  min-height: 100svh;
  min-height: 100dvh;
  background:
    linear-gradient(180deg, rgba(255, 60, 157, 0.14), transparent 28%),
    linear-gradient(120deg, rgba(82, 223, 255, 0.1), transparent 42%),
    linear-gradient(240deg, rgba(86, 240, 160, 0.08), transparent 48%),
    var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

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

button {
  font: inherit;
}

.darts-page {
  position: relative;
  width: min(100%, 390px);
  height: 100svh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 10px 10px max(10px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-content: stretch;
  gap: 10px;
}

.entry-gate {
  position: absolute;
  inset: 0;
  z-index: 18;
  display: grid;
  place-items: center;
  padding: 24px 18px;
  overflow: hidden;
  background: #030305;
  opacity: 1;
  transition:
    opacity 720ms ease,
    filter 720ms ease;
}

.entry-gate[hidden] {
  display: none;
}

.entry-gate::after {
  content: "";
  position: absolute;
  width: 34%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 198, 90, 0.12);
  filter: blur(30px);
  transform: translateY(-10%);
  opacity: 0.6;
  transition:
    opacity 720ms ease,
    transform 720ms ease;
  pointer-events: none;
}

.entry-gate.is-exiting {
  opacity: 0;
  filter: brightness(1.5);
  pointer-events: none;
}

.entry-gate.is-exiting::after {
  opacity: 1;
  transform: scale(3.8);
}

.entry-enter {
  position: relative;
  z-index: 1;
  width: min(74%, 288px);
  min-height: 44px;
  padding: 0;
  display: grid;
  justify-items: center;
  gap: 11px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  touch-action: manipulation;
}

.entry-card {
  width: min(62%, 248px);
  height: auto;
  display: block;
  border-radius: 0;
  mask-image: radial-gradient(ellipse at center, #000 0 43%, rgba(0, 0, 0, 0.96) 55%, rgba(0, 0, 0, 0.48) 68%, transparent 82%);
  -webkit-mask-image: radial-gradient(ellipse at center, #000 0 43%, rgba(0, 0, 0, 0.96) 55%, rgba(0, 0, 0, 0.48) 68%, transparent 82%);
  mask-repeat: no-repeat;
  -webkit-mask-repeat: no-repeat;
  mask-size: 100% 100%;
  -webkit-mask-size: 100% 100%;
  filter:
    drop-shadow(0 22px 46px rgba(0, 0, 0, 0.54))
    drop-shadow(0 0 20px rgba(255, 198, 90, 0.12));
  animation: entry-breathe 2.8s ease-in-out infinite;
}

.entry-hint {
  display: block;
  min-height: 18px;
  opacity: 1;
  color: rgba(255, 247, 230, 0.62);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-shadow: 0 0 16px rgba(255, 198, 90, 0.34);
  animation: entry-hint-in 360ms ease both;
}

.entry-hint[hidden] {
  display: block;
  visibility: hidden;
  opacity: 0;
  animation: none;
}

@keyframes entry-breathe {
  0%,
  100% {
    transform: translateY(0);
    filter:
      drop-shadow(0 22px 46px rgba(0, 0, 0, 0.54))
      drop-shadow(0 0 16px rgba(255, 198, 90, 0.1));
  }

  50% {
    transform: translateY(-2px);
    filter:
      drop-shadow(0 24px 48px rgba(0, 0, 0, 0.56))
      drop-shadow(0 0 24px rgba(255, 198, 90, 0.18));
  }
}

@keyframes entry-hint-in {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 24px;
  background: #09070d;
  text-align: center;
}

.loading-screen[hidden] {
  display: none;
}

.loading-mark {
  width: 54px;
  height: 54px;
  border: 2px solid rgba(255, 198, 90, 0.28);
  border-top-color: var(--cyan);
  border-right-color: var(--pink);
  border-radius: 8px;
  box-shadow: 0 0 24px rgba(82, 223, 255, 0.24);
  animation: loading-spin 1.1s linear infinite;
}

.loading-screen p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.loading-track {
  width: min(78vw, 340px);
  height: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 198, 90, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.loading-track span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--amber), var(--pink), var(--cyan));
  box-shadow: 0 0 18px rgba(255, 60, 157, 0.38);
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

.darts-topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.home-link,
.balance-pill,
.status-strip,
.control-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(16px);
}

.home-link {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
}

.home-link img {
  width: 30px;
  height: 30px;
}

.title-block {
  min-width: 0;
}

.title-block p,
.status-strip span,
.stake-label,
.summary-panel span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  letter-spacing: 0;
}

.title-block p {
  margin: 0;
  color: var(--cyan);
}

.title-block h1 {
  margin: 2px 0 0;
  font-size: 1.375rem;
  line-height: 1;
  letter-spacing: 0;
}

.balance-pill {
  min-width: 96px;
  max-width: 132px;
  height: 44px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  border-radius: 8px;
  color: var(--amber);
  font-weight: 800;
}

.balance-pill img {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
}

.balance-pill span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.play-shell {
  position: relative;
  width: 100%;
  min-height: 0;
  align-self: start;
  justify-self: center;
  overflow: hidden;
  border: 1px solid rgba(255, 198, 90, 0.2);
  border-radius: 8px;
  background: #0a090f;
  box-shadow:
    inset 0 0 0 1px rgba(82, 223, 255, 0.08),
    0 24px 54px rgba(0, 0, 0, 0.38);
}

.board-stage {
  position: relative;
  min-height: 0;
  aspect-ratio: 368 / 456;
}

#barDartsCanvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #0a090f;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.status-strip {
  position: absolute;
  z-index: 3;
  top: 10px;
  left: 10px;
  right: 10px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  padding: 6px;
  border-color: var(--line-hot);
  border-radius: 8px;
  pointer-events: none;
}

.status-strip div {
  min-width: 0;
  padding: 2px 4px;
}

.status-strip strong {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-panel[hidden],
.supply-action[hidden] {
  display: none;
}

.summary-panel h2 {
  display: block;
  margin: 2px 0 0;
  color: var(--text);
  font-size: 19px;
  line-height: 1.15;
  letter-spacing: 0;
}

.summary-panel p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.summary-panel .reward-formula {
  margin-top: 5px;
  color: var(--amber);
  font-weight: 800;
  line-height: 1.25;
}

.control-panel {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
}

.control-panel.is-summary .stake-row,
.control-panel.is-summary .target-row {
  display: none;
}

.control-panel.is-ready .target-row {
  display: none;
}

.control-panel.is-playing .stake-row {
  display: none;
}

.stake-row,
.target-row {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.stake-options,
.target-options {
  display: flex;
  gap: 8px;
  min-width: 0;
}

.stake-options button,
.target-options button,
.primary-action,
.supply-action {
  min-height: 44px;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.stake-options button,
.target-options button {
  min-width: 74px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.target-options button {
  min-height: 58px;
  padding: 6px 5px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1px;
  white-space: normal;
}

.target-main,
.target-sub {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  line-height: 1.08;
  letter-spacing: 0;
}

.target-main {
  color: inherit;
  font-size: 1rem;
  font-weight: 850;
}

.target-sub {
  color: inherit;
  font-size: 0.5rem;
  font-weight: 650;
  opacity: 0.84;
}

.stake-options button[aria-checked="true"],
.target-options button[aria-checked="true"] {
  border-color: transparent;
  background: linear-gradient(135deg, var(--amber), #ff8fc9);
  color: #180b12;
  font-weight: 800;
}

.stake-hint,
.target-hint {
  margin: 0;
  color: var(--amber);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.target-hint {
  color: var(--cyan);
}

.stake-hint::before,
.target-hint::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 5px;
  border-radius: 999px;
  background: var(--amber);
  box-shadow: 0 0 10px rgba(255, 198, 90, 0.7);
  vertical-align: 1px;
}

.target-hint::before {
  background: var(--cyan);
  box-shadow: 0 0 10px rgba(82, 223, 255, 0.7);
}

.primary-action {
  min-width: 144px;
  padding: 0 18px;
  border: 0;
  background: linear-gradient(135deg, var(--amber), var(--pink));
  box-shadow: 0 0 24px rgba(255, 60, 157, 0.38);
  color: #150910;
  font-weight: 800;
}

.primary-action:disabled {
  cursor: wait;
  filter: grayscale(0.6);
  opacity: 0.72;
}

.summary-panel {
  min-width: 0;
  padding: 8px 2px 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
}

.score-breakdown {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  margin-top: 9px;
}

.score-breakdown:empty {
  display: none;
}

.score-breakdown-row {
  min-height: 30px;
  padding: 6px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.1;
}

.score-breakdown-row strong {
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
}

.score-breakdown-row:last-child {
  grid-column: 1 / -1;
  border-color: rgba(255, 198, 90, 0.28);
  background: rgba(255, 198, 90, 0.1);
}

.supply-action {
  width: 100%;
  margin-top: 10px;
  padding: 0 14px;
  border: 0;
  background: var(--green);
  color: #07100b;
  font-weight: 800;
}

.stake-label {
  display: none;
}

.stake-options,
.target-options {
  justify-content: stretch;
}

.stake-options button,
.target-options button,
.primary-action,
.supply-action {
  width: 100%;
}

@media (max-width: 420px) {
  .home-link,
  .balance-pill {
    height: 40px;
  }

  .home-link {
    width: 40px;
  }

  .status-strip {
    top: 8px;
    left: 8px;
    right: 8px;
    gap: 4px;
  }

  .status-strip div {
    padding-inline: 2px;
  }

  .status-strip span {
    font-size: 10px;
  }

  .status-strip strong {
    font-size: 0.82rem;
  }

  .stake-options,
  .target-options {
    gap: 6px;
  }

  .stake-options button,
  .target-options button {
    min-width: 0;
    padding-inline: 8px;
  }

  .target-options button {
    min-height: 56px;
    padding-inline: 5px;
  }

  .target-main {
    font-size: 0.96rem;
  }

  .target-sub {
    font-size: 0.5rem;
  }
}

@media (max-height: 760px) {
  .darts-page {
    padding: 6px 8px max(6px, env(safe-area-inset-bottom));
    gap: 6px;
  }

  .title-block p {
    display: none;
  }

  .title-block h1 {
    margin-top: 0;
    font-size: 1.12rem;
  }

  .play-shell {
    width: min(100%, max(304px, calc((100svh - 236px) * 368 / 456)));
  }

  .control-panel {
    gap: 7px;
    padding: 8px;
  }

  .stake-row,
  .target-row {
    gap: 4px;
  }

  .stake-hint,
  .target-hint {
    font-size: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto;
  }

  .loading-mark {
    animation: none;
  }
}
