:root {
  color-scheme: dark;
  --ink: #f6e7d4;
  --muted: #e4c7a4;
  --line: #e0a36a;
  --panel: rgba(28, 18, 26, 0.88);
  --yuan: #f0c14a;
  --mao: #8fd4cb;
  font-family: "PingFang SC", "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", "WenQuanYi Micro Hei", "Droid Sans Fallback", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #22162e;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: fixed;
  inset: 0;
}

#view {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#names {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.name-tag {
  position: absolute;
  transform: translate(-50%, -130%);
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(18, 10, 16, 0.82);
  color: #f6e7d4;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.3;
  white-space: nowrap;
}

.name-tag.yuan { color: #f0c14a; }
.name-tag.mao { color: #8fd4cb; }

.panel {
  position: absolute;
  z-index: 2;
  color: var(--ink);
}

#title {
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  pointer-events: none;
}

#title .card,
#paused .card,
#result .card {
  pointer-events: auto;
  width: min(400px, 68vw);
  max-height: calc(100dvh - 24px);
  overflow: auto;
  background: rgba(28, 18, 26, 0.96);
  border: 1px solid rgba(224, 163, 106, 0.65);
  border-radius: 22px;
  padding: 16px 16px 12px;
  text-align: center;
}

@media (max-aspect-ratio: 1/1) {
  #title .card { width: min(200px, 50vw); }
  #title h1 { font-size: 32px; letter-spacing: 0.08em; }
  .park { font-size: 18px; padding: 6px 12px; }
  .park-note { margin: 4px 0 8px; font-size: 14px; }
}

h1 {
  margin: 0;
  font-size: clamp(40px, 8vw, 68px);
  font-weight: 750;
  letter-spacing: 0.14em;
}

.en {
  margin: 2px 0 12px;
  color: var(--muted);
  letter-spacing: 0.18em;
}

.park {
  display: inline-block;
  margin: 4px 0;
  padding: 8px 18px;
  border: 2px solid var(--line);
  border-radius: 999px;
  color: #ffe7c4;
  font-size: clamp(22px, 4vw, 32px);
  font-weight: 750;
}

.park-note {
  margin: 8px 0 14px;
  color: var(--muted);
}

.row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 8px 0;
}

button {
  font: inherit;
  color: var(--ink);
  background: #3a2a30;
  border: 1px solid rgba(240, 193, 74, 0.35);
  border-radius: 14px;
  min-height: 48px;
  padding: 10px 16px;
  cursor: pointer;
}

button.on,
button.focus {
  outline: 3px solid #f2d7a2;
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

#start-solo, #start-duo, #again, #resume {
  min-width: 132px;
  background: #6a432c;
}

.help {
  margin: 12px 0 0;
  text-align: left;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.help b { color: var(--ink); font-weight: 650; }

#pads {
  margin: 8px 0 0;
  color: #f0d7b4;
  font-size: 13px;
}

#hud {
  position: absolute;
  z-index: 2;
  inset: 0;
  padding: 10px 12px;
  pointer-events: none;
}

#scores {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-right: 84px;
}

.score {
  min-width: 92px;
  padding: 6px 10px 8px;
  border-radius: 14px;
  background: rgba(24, 14, 20, 0.62);
}

.score span { display: block; font-size: 14px; color: var(--muted); }
.score b { font-size: 28px; line-height: 1.1; }
.score.yuan b { color: var(--yuan); }
.score.mao b { color: var(--mao); }
.score small { display: block; color: var(--muted); }

#banner {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  min-height: 0;
  text-align: center;
  pointer-events: none;
}

#banner:not(:empty) {
  width: fit-content;
  max-width: calc(100% - 24px);
  margin: 0 auto;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(18, 10, 16, 0.88);
  border: 1px solid rgba(255, 214, 160, 0.5);
  color: #ffe7c4;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
  animation: pulse 0.9s ease-in-out infinite;
}

@keyframes pulse {
  50% { opacity: 0.55; }
}

#pause-btn {
  pointer-events: auto;
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  background: rgba(24, 14, 20, 0.72);
}

#paused, #result {
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#paused .help div,
#result .card {
  text-wrap: pretty;
}

#paused .help div {
  margin: 4px 0;
}

#paused[hidden],
#result[hidden],
#title[hidden],
#hud[hidden],
#pause-btn[hidden] { display: none; }

.why { margin: 0; font-size: 22px; }
.big {
  margin: 4px 0 8px;
  font-size: 40px;
  color: var(--yuan);
}
.compare {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.compare .score { flex: 1; }
.compare .winner { outline: 2px solid #ffe7c4; }

#halves {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  pointer-events: none;
}
#halves[hidden] { display: none; }
.half {
  flex: 1;
  display: flex;
  align-items: flex-end;
  padding: 16px;
}
.half.yuan {
  justify-content: flex-start;
  background: linear-gradient(90deg, rgba(240, 193, 74, 0.16), transparent 46%);
}
.half.mao {
  justify-content: flex-end;
  background: linear-gradient(270deg, rgba(143, 212, 203, 0.16), transparent 46%);
}
.half span {
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(18, 10, 16, 0.4);
  font-size: 14px;
  font-weight: 700;
}
.half.yuan span { color: var(--yuan); }
.half.mao span { color: var(--mao); }

.fine {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}
