:root {
  --deep: #0b3d6b;
  --sea: #1a6aa6;
  --sea-d: #0b4f7c;
  --foam: #e8f6ff;
  --pink: #ff8fb8;
  --pink-d: #d9568a;
  --pink-deep: #ff5d8f;
  --ink: #103a5e;
  --card: rgba(255, 255, 255, 0.95);
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--deep);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#hud button,
#joy { pointer-events: auto; }

.top {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pill {
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 4px 14px rgba(0, 30, 60, 0.25);
  white-space: nowrap;
}

.btn-mini {
  border: 0;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  color: var(--sea-d);
}

.timer {
  display: flex;
  align-items: baseline;
  gap: 4px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  padding: 6px 18px;
  box-shadow: 0 6px 18px rgba(0, 30, 60, 0.3);
  color: var(--sea-d);
}

.timer .lbl { font-size: 12px; font-weight: 700; color: #6b93b3; }
.timer #tnum {
  font-size: 30px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
  text-align: center;
}
.timer .unit { font-size: 13px; font-weight: 700; }

.timer.danger #tnum {
  color: var(--pink-deep);
  animation: beat 0.6s ease-in-out infinite;
}

@keyframes beat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

.toast {
  position: absolute;
  top: 92px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.96);
  color: var(--pink-d);
  font-weight: 900;
  font-size: 18px;
  padding: 8px 20px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(0, 30, 60, 0.25);
  opacity: 0;
  pointer-events: none;
}

.toast.show { animation: toastIn 1.8s ease forwards; }

@keyframes toastIn {
  0% { opacity: 0; transform: translate(-50%, -10px) scale(0.9); }
  12% { opacity: 1; transform: translate(-50%, 0) scale(1.04); }
  20% { transform: translate(-50%, 0) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -6px); }
}

#big {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  font-size: 120px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 6px 0 var(--pink-d), 0 0 34px rgba(255, 143, 184, 0.7);
  opacity: 0;
  pointer-events: none;
}

#big:not(:empty).pop { animation: bigPop 0.95s ease-out both; }

@keyframes bigPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  60% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.1); }
}

.kbd {
  position: absolute;
  left: 12px;
  bottom: max(10px, env(safe-area-inset-bottom));
  font-size: 12px;
  color: #fff;
  background: rgba(0, 30, 60, 0.4);
  padding: 5px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.touch {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  padding: 16px max(18px, env(safe-area-inset-left)) max(22px, env(safe-area-inset-bottom));
}

@media (pointer: coarse) {
  .touch { display: flex; }
  .kbd { display: none; }
}

#joy {
  position: relative;
  width: 136px;
  height: 136px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  border: 2px solid rgba(255, 255, 255, 0.5);
  touch-action: none;
}

#knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 12px rgba(0, 30, 60, 0.3);
  pointer-events: none;
}

.acts {
  display: flex;
  gap: 14px;
  align-items: flex-end;
}

.round {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.92);
  color: var(--sea-d);
  font: inherit;
  font-weight: 900;
  font-size: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-shadow: 0 6px 0 #b6d6ea, 0 10px 20px rgba(0, 30, 60, 0.25);
  cursor: pointer;
}

.round small { font-size: 11px; font-weight: 700; color: #6b93b3; }

.round.pink {
  background: var(--pink);
  color: #fff;
  box-shadow: 0 6px 0 var(--pink-d), 0 10px 20px rgba(0, 30, 60, 0.25);
}

.round.pink small { color: #fff; opacity: 0.9; }

.round:disabled { opacity: 0.55; }

.round.crouching {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #b6d6ea;
}

/* ---------- 屏幕卡片 ---------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  background: radial-gradient(ellipse at center, rgba(5, 40, 75, 0.25), rgba(5, 40, 75, 0.6));
}

.card {
  width: min(92vw, 400px);
  margin: auto;
  background: var(--card);
  border-radius: 28px;
  padding: 26px 22px 22px;
  box-shadow: 0 24px 60px rgba(0, 20, 40, 0.4);
  text-align: center;
  animation: pop 0.45s cubic-bezier(0.2, 1.3, 0.4, 1);
}

@keyframes pop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.kicker {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--pink-d);
}

h1 {
  margin: 6px 0 4px;
  font-size: 38px;
  line-height: 1.15;
  font-weight: 900;
  color: var(--sea-d);
}

h1 span {
  display: inline-block;
  color: var(--pink);
  text-shadow: 0 3px 0 #fff, 0 4px 0 var(--pink-d);
}

h2 {
  margin: 4px 0 6px;
  font-size: 34px;
  font-weight: 900;
  color: var(--pink-d);
}

h2.win { color: var(--sea); }

.lead {
  margin: 4px 0 0;
  font-size: 15px;
  color: #3d6a8c;
  font-weight: 600;
}

.sub {
  margin: 18px 0 8px;
  font-size: 13px;
  font-weight: 800;
  color: #6b93b3;
  letter-spacing: 2px;
}

.diffs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.diff {
  font: inherit;
  font-size: 16px;
  font-weight: 900;
  color: var(--sea);
  background: #f2faff;
  border: 2px solid #cfe6f5;
  border-radius: 16px;
  padding: 11px 4px;
  cursor: pointer;
  transition: transform 0.1s;
}

.diff:active { transform: scale(0.96); }

.diff[aria-pressed="true"] {
  background: var(--sea);
  color: #fff;
  border-color: var(--sea);
  box-shadow: 0 5px 0 var(--sea-d);
}

.desc {
  min-height: 22px;
  margin: 10px 0 0;
  font-size: 13px;
  color: #3d6a8c;
  font-weight: 700;
}

.records {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 8px;
  margin: 14px 0 6px;
}

.records > div {
  background: linear-gradient(180deg, #ffffff, #eef8ff);
  border: 2px solid #dbeef9;
  border-radius: 16px;
  padding: 8px 2px 6px;
}

.records b {
  display: block;
  font-size: 22px;
  font-weight: 900;
  color: var(--sea-d);
  font-variant-numeric: tabular-nums;
}

.records span {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 700;
  color: #6b93b3;
}

.rules {
  text-align: left;
  font-size: 13px;
  line-height: 1.75;
  color: #35607f;
  padding-left: 20px;
  margin: 12px 0 18px;
}

.btn {
  display: block;
  width: 100%;
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 14px 24px;
  margin-top: 10px;
  font: inherit;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #fff;
  background: var(--pink);
  box-shadow: 0 6px 0 var(--pink-d), 0 10px 22px rgba(217, 86, 138, 0.35);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}

.btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--pink-d);
}

.btn.ghost {
  color: var(--sea);
  background: #fff;
  box-shadow: 0 6px 0 #b6d6ea, 0 10px 22px rgba(0, 30, 60, 0.15);
}

.btn.ghost:active { box-shadow: 0 2px 0 #b6d6ea; }

.btn:focus-visible,
.round:focus-visible,
.diff:focus-visible,
.btn-mini:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

@media (max-height: 640px) {
  .card { padding: 18px 18px 16px; }
  h1 { font-size: 30px; }
  .rules { margin: 8px 0 12px; }
}
