:root {
  --bg: #141c24;
  --card: rgba(16, 22, 30, 0.78);
  --text: #f3efe6;
  --muted: #b9c3cc;
  --accent: #e45b4c;
  --safe: #3dd69a;
  --warn: #f0c14b;
  --glass: rgba(255, 255, 255, 0.08);
  --stroke: rgba(255, 255, 255, 0.14);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
  font-family: "PingFang HK", "PingFang TC", "Noto Sans TC", "Noto Sans CJK TC",
    "Microsoft JhengHei", ui-sans-serif, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  position: fixed;
  inset: 0;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

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

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: none;
}

#hud {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  padding: calc(10px + env(safe-area-inset-top)) 16px 0;
  pointer-events: none;
  z-index: 2;
}

#hud[hidden] {
  display: none;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.timer-wrap {
  display: flex;
  align-items: baseline;
  gap: 6px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.55);
}

#hud-time {
  font-size: clamp(36px, 11vw, 56px);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.hud-unit {
  font-size: 16px;
  opacity: 0.8;
}

.hud-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: auto;
}

.best-chip,
.lang-mini {
  background: rgba(12, 16, 22, 0.55);
  border: 1px solid var(--stroke);
  color: var(--text);
  border-radius: 999px;
  backdrop-filter: blur(10px);
}

.best-chip {
  pointer-events: none;
  padding: 6px 10px;
  font-size: 12px;
  display: flex;
  gap: 6px;
  align-items: baseline;
}

.lang-mini {
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.meter-block {
  margin-top: 10px;
  max-width: 520px;
}

.meter-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: none;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
  margin-bottom: 6px;
}

.meter {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: rgba(8, 10, 14, 0.55);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--warn), var(--safe));
  background-size: 100vw 100%;
  transform-origin: left;
  transition: width 80ms linear;
}

.meter-mark {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25);
}

.danger-row {
  margin-top: 8px;
  color: #ffd2cc;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  gap: 8px;
  animation: pulse 0.7s ease-in-out infinite;
}

.event-toast {
  margin-top: 10px;
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(12, 16, 22, 0.6);
  border: 1px solid var(--stroke);
  font-size: 13px;
  font-weight: 600;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  background: linear-gradient(
    180deg,
    rgba(10, 14, 18, 0.08) 0%,
    rgba(10, 14, 18, 0.55) 38%,
    rgba(10, 14, 18, 0.82) 100%
  );
}

.screen.hidden {
  display: none;
}

.screen-card {
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 28px;
  padding: 22px 20px 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.kicker,
.over-kicker {
  margin: 0 0 8px;
  color: #f3c27a;
  font-size: 12px;
  letter-spacing: 0.16em;
}

h1 {
  margin: 0 0 12px;
  line-height: 1.05;
}

h1 .zh {
  display: block;
  font-size: clamp(34px, 10vw, 48px);
  font-weight: 800;
}

h1 .en {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.08em;
}

.lead,
.how,
.privacy,
.disclaimer,
.end-best,
.share-status {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.how {
  color: var(--text);
  margin-bottom: 18px;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 14px 18px;
  font: inherit;
  font-weight: 700;
  font-size: 16px;
  width: 100%;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  color: #fff8f5;
  box-shadow: 0 8px 24px rgba(228, 91, 76, 0.35);
}

.btn.ghost {
  margin-top: 10px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--stroke);
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 8px 0 12px;
}

.btn-row .btn {
  margin: 0;
}

.privacy {
  font-size: 12px;
  margin-top: 12px;
}

.disclaimer {
  font-size: 11px;
  opacity: 0.85;
  margin-bottom: 0;
}

.end-card {
  text-align: center;
}

.lasted-label {
  margin: 0;
  font-size: 18px;
}

.score-line {
  margin: 4px 0 8px;
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 8px;
}

#end-score {
  font-size: clamp(64px, 22vw, 96px);
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 0.9;
  color: #fff7ea;
}

.new-best {
  display: inline-block;
  margin: 0 auto 10px;
  padding: 4px 12px;
  border-radius: 999px;
  background: #f0c14b;
  color: #2a1d08;
  font-weight: 800;
  font-size: 13px;
}

.new-best[hidden] {
  display: none;
}

.share-status {
  min-height: 1.2em;
  color: var(--safe);
}

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

@media (min-width: 720px) {
  .screen {
    align-items: center;
  }

  .screen-card {
    padding: 28px 26px 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .danger-row,
  .meter-fill {
    animation: none;
    transition: none;
  }
}
