﻿:root {
  --bg-1: #f7f1e6;
  --bg-2: #efe1c8;
  --card: #fffdf7;
  --text: #1f1a12;
  --muted: #6b5d48;
  --accent: #2f8f6b;
  --accent-2: #1d6b4f;
  --line: #dcccae;
  --danger: #9c2f2f;
  --ok: #1f7a42;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Segoe UI", "Noto Sans KR", sans-serif;
  background: radial-gradient(circle at 20% 0%, #fff8ea, var(--bg-1) 40%, var(--bg-2));
  color: var(--text);
}

body {
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.app {
  max-width: 540px;
  margin: 0 auto;
  display: grid;
  gap: 12px;
}

.card {
  background: color-mix(in srgb, var(--card) 93%, #fff 7%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 8px 20px rgba(44, 33, 10, 0.08);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 1.3rem;
}

h2 {
  font-size: 1.05rem;
  margin-bottom: 8px;
}

h3 {
  margin-top: 10px;
  margin-bottom: 6px;
  font-size: 0.95rem;
}

.hero p {
  margin-top: 6px;
  color: var(--muted);
}

.welcome {
  font-weight: 700;
}

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

.btn {
  min-height: 48px;
  border: 0;
  border-radius: 10px;
  padding: 10px;
  font-size: 1rem;
  font-weight: 700;
  touch-action: manipulation;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease, opacity 120ms ease;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.choice {
  background-image: url("./assets/ui/pick-heads.png");
  background-color: transparent;
  color: #5b4723;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

#pick-tails.choice {
  background-image: url("./assets/ui/pick-tails.png");
}

.choice.active {
  filter: saturate(1.06) brightness(1.03);
}

.picked {
  margin-top: 8px;
  color: var(--muted);
}

.arena {
  text-align: center;
}

.coin-wrap {
  display: flex;
  justify-content: center;
  margin: 8px 0 12px;
}

.coin {
  width: 104px;
  aspect-ratio: 1;
  display: block;
  background-image: url("./assets/ui/coin-heads.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.coin.coin-tails {
  background-image: url("./assets/ui/coin-tails.png");
}

.coin.tossing {
  animation: spin 0.95s ease-in-out;
}

@keyframes spin {
  0% {
    transform: rotateY(0deg) scale(1);
  }
  30% {
    transform: rotateY(360deg) scale(1.08);
  }
  60% {
    transform: rotateY(900deg) scale(0.97);
  }
  100% {
    transform: rotateY(1260deg) scale(1);
  }
}

.toss {
  width: 100%;
  background-image: url("./assets/ui/toss-idle.png");
  background-color: transparent;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
}

.toss:active {
  background-image: url("./assets/ui/toss-pressed.png");
}

.toss[disabled] {
  filter: grayscale(0.25);
  opacity: 0.62;
  cursor: not-allowed;
}

.status {
  margin-top: 8px;
  min-height: 1.4em;
  font-weight: 700;
}

.status.ok {
  color: var(--ok);
}

.status.fail {
  color: var(--danger);
}

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

.grid > div {
  background: url("./assets/ui/stat-panel.png") center / 100% 100% no-repeat;
  border: 0;
  border-radius: 10px;
  padding: 8px;
  display: grid;
  gap: 4px;
}

.grid strong {
  color: #5b4c33;
  font-size: 0.85rem;
}

.best-label {
  padding-left: 22px;
  background: url("./assets/ui/best-badge.png") left center / 18px 18px no-repeat;
}

.grid span {
  font-weight: 800;
}

.recent {
  margin: 0;
  padding-left: 22px;
  display: grid;
  gap: 2px;
  color: #4f412c;
  min-height: 24px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 720px) {
  .app {
    max-width: 760px;
    grid-template-columns: 1fr 1fr;
  }

  .hero,
  .stats {
    grid-column: 1 / -1;
  }
}
