@charset "utf-8";

:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", sans-serif;
  font-synthesis: none;
  color: #f5f1df;
  background: #071811;
  --ink: #091711;
  --panel: #10251d;
  --panel-raised: #183328;
  --line: rgba(218, 237, 206, .18);
  --text-soft: #c1d1bf;
  --gold: #ffd982;
  --tiger: #ff9d43;
  --panda: #55e5c6;
}

* { box-sizing: border-box; }
html { min-width: 280px; min-height: 100%; background: var(--ink); }
body {
  min-width: 280px;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  color: #f5f1df;
  background:
    radial-gradient(ellipse at 50% -18%, rgba(244, 202, 103, .28), transparent 46%),
    radial-gradient(ellipse at 4% 38%, rgba(43, 157, 111, .24), transparent 37%),
    radial-gradient(ellipse at 96% 60%, rgba(30, 139, 133, .20), transparent 39%),
    linear-gradient(160deg, #0b2118 0%, #071711 49%, #0b201a 100%);
  overflow-x: clip;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .2;
  background:
    repeating-linear-gradient(118deg, transparent 0 46px, rgba(220, 240, 201, .035) 47px 48px, transparent 49px 95px),
    radial-gradient(ellipse at 50% 45%, transparent 25%, rgba(0, 0, 0, .38) 100%);
}
body::after {
  content: "";
  position: fixed;
  z-index: 0;
  left: 50%;
  top: 38%;
  width: min(84vw, 520px);
  aspect-ratio: 1;
  border: 1px solid rgba(255, 223, 144, .075);
  border-radius: 50%;
  box-shadow: 0 0 0 18px rgba(225, 220, 157, .018), 0 0 0 42px rgba(225, 220, 157, .014), inset 0 0 72px rgba(102, 191, 142, .06);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
button, input { font: inherit; }
button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 15px;
  color: #f5f1df;
  background: linear-gradient(180deg, rgba(42, 65, 49, .94), rgba(22, 44, 33, .98));
  cursor: pointer;
  touch-action: manipulation;
  font-weight: 700;
  transition: transform 140ms ease, filter 140ms ease, box-shadow 180ms ease, background-color 180ms ease;
}
button:active:not(:disabled) { transform: translateY(2px) scale(.985); filter: brightness(1.1); }
button:disabled { opacity: .43; cursor: default; filter: saturate(.55); }
button:focus-visible, input:focus-visible { outline: 3px solid #fff0a6; outline-offset: 3px; }
.app {
  position: relative;
  z-index: 1;
  width: min(100%, 610px);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding:
    max(20px, env(safe-area-inset-top))
    max(15px, env(safe-area-inset-right))
    max(22px, env(safe-area-inset-bottom))
    max(15px, env(safe-area-inset-left));
}
.app::before {
  content: "";
  position: absolute;
  inset: 10px 7px 12px;
  z-index: -1;
  border: 1px solid rgba(236, 225, 171, .08);
  border-radius: 30px;
  pointer-events: none;
}
header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.eyebrow {
  margin: 0 0 6px;
  color: #d6cb8f;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 2.8px;
}
.eyebrow span {
  display: inline-block;
  margin-left: 5px;
  padding: 3px 7px;
  border: 1px solid rgba(228, 202, 114, .35);
  border-radius: 999px;
  color: #f1d88a;
  background: rgba(177, 135, 50, .12);
  font-size: 9px;
  letter-spacing: .5px;
  vertical-align: 1px;
}
h1 {
  max-width: 100%;
  margin: 0;
  color: #fff8dd;
  font-size: clamp(25px, 6.5vw, 35px);
  font-weight: 900;
  letter-spacing: -.8px;
  line-height: 1.16;
  text-shadow: 0 2px 20px rgba(245, 206, 121, .2);
  overflow-wrap: anywhere;
}
h2 { margin: 0; color: #fff3d0; font-size: 21px; }
.icon-button {
  flex: 0 0 48px;
  width: 48px;
  min-height: 48px;
  border-color: rgba(220, 231, 193, .2);
  border-radius: 50%;
  color: #f4df9f;
  background: rgba(212, 193, 112, .09);
  font-size: 22px;
  backdrop-filter: blur(10px);
}
.update-status {
  margin: 10px 0 0;
  padding: 11px 13px;
  border: 1px solid rgba(255, 217, 130, .48);
  border-radius: 13px;
  color: #fff3ce;
  background: rgba(79, 61, 27, .8);
  font-size: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.update-status[data-state="failed"] {
  border-color: rgba(255, 174, 145, .58);
  color: #ffe2d5;
  background: rgba(89, 39, 29, .82);
}
.local-note {
  display: flex;
  align-items: center;
  gap: 9px;
  width: fit-content;
  max-width: 100%;
  margin: 15px 0 17px;
  padding: 8px 12px;
  border: 1px solid rgba(119, 218, 157, .2);
  border-radius: 999px;
  color: #c8dbc8;
  background: rgba(30, 73, 47, .38);
  font-size: 11px;
  line-height: 1.35;
}
.dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #85efae;
  box-shadow: 0 0 9px rgba(125, 244, 164, .82);
}
.round-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 9px 13px;
  border: 1px solid rgba(235, 223, 167, .21);
  border-radius: 15px;
  color: #fff0c6;
  background: linear-gradient(100deg, rgba(78, 67, 31, .56), rgba(19, 46, 35, .86) 48%, rgba(27, 64, 57, .7));
  box-shadow: inset 0 1px rgba(255, 255, 255, .08), 0 8px 24px rgba(0, 0, 0, .15);
  font-size: 12px;
}
.round-bar span:first-child { color: #ffe09a; font-size: 14px; font-weight: 850; }
.round-bar span:last-child { color: var(--text-soft); text-align: right; }
.teams {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: clamp(9px, 3vw, 15px);
  padding-top: 16px;
}
.teams::before {
  content: "VS";
  position: absolute;
  z-index: 4;
  top: 43%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 228, 150, .65);
  border-radius: 50%;
  color: #fff3c6;
  background: linear-gradient(145deg, #725831, #263c2d 76%);
  box-shadow: 0 0 16px rgba(246, 199, 100, .24), inset 0 1px rgba(255,255,255,.3);
  font-size: 10px;
  font-weight: 950;
  letter-spacing: .8px;
  transform: translateX(-50%);
  pointer-events: none;
}
.team {
  --accent: var(--tiger);
  --accent-bright: #ffd28a;
  --glow: rgba(255, 143, 48, .28);
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 10px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--accent) 48%, transparent);
  border-radius: 23px;
  background: linear-gradient(154deg, rgba(44, 43, 31, .96), rgba(16, 37, 29, .98) 50%, rgba(13, 31, 25, .98));
  box-shadow: 0 14px 32px rgba(0, 0, 0, .28), inset 0 1px rgba(255, 255, 255, .12), 0 0 20px var(--glow);
}
.team::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 30%, var(--glow), transparent 58%),
    linear-gradient(135deg, rgba(255,255,255,.06), transparent 29%);
}
.team::after {
  content: "";
  position: absolute;
  top: 0;
  right: 16%;
  width: 38%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-bright), transparent);
  box-shadow: 0 0 13px var(--accent);
}
.team[data-theme="panda"] {
  --accent: var(--panda);
  --accent-bright: #bdffdf;
  --glow: rgba(58, 218, 184, .24);
  background: linear-gradient(154deg, rgba(26, 56, 47, .97), rgba(13, 39, 39, .98) 55%, rgba(10, 31, 29, .98));
}
.team-heading { position: relative; z-index: 1; display: flex; min-width: 0; align-items: center; gap: 8px; }
.team-crest {
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid color-mix(in srgb, var(--accent-bright) 58%, transparent);
  border-radius: 15px;
  color: white;
  background: radial-gradient(circle at 34% 22%, color-mix(in srgb, var(--accent) 44%, white), color-mix(in srgb, var(--accent) 15%, #10251d) 68%);
  box-shadow: 0 0 14px var(--glow), inset 0 1px rgba(255,255,255,.28);
  font-size: 22px;
}
.team-name {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 48px;
  padding: 3px 0;
  border: 0;
  border-radius: 8px;
  color: #fff4d5;
  background: transparent;
  text-align: left;
  font-size: 14px;
  font-weight: 850;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.team-name small {
  display: block;
  margin-top: 3px;
  color: #c1cbbb;
  font-size: 9px;
  font-weight: 600;
}
.score-card {
  position: relative;
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: space-between;
  margin-top: 9px;
  padding: 10px 9px 9px;
  overflow: hidden;
  border: 1px solid rgba(244, 226, 172, .25);
  border-radius: 17px;
  color: var(--accent-bright);
  background:
    radial-gradient(ellipse at 50% 47%, var(--glow), transparent 70%),
    linear-gradient(155deg, rgba(9, 22, 17, .8), rgba(22, 43, 31, .92));
  box-shadow: inset 0 1px rgba(255,255,255,.1), inset 0 0 24px rgba(0,0,0,.18);
}
.score-card::before, .score-card::after {
  content: "";
  position: absolute;
  width: 25px;
  height: 25px;
  border-color: color-mix(in srgb, var(--accent-bright) 54%, transparent);
  opacity: .64;
  pointer-events: none;
}
.score-card::before { top: 6px; left: 6px; border-top: 1px solid; border-left: 1px solid; border-radius: 8px 0 0; }
.score-card::after { right: 6px; bottom: 6px; border-right: 1px solid; border-bottom: 1px solid; border-radius: 0 0 8px; }
.card-label {
  position: relative;
  z-index: 1;
  color: #d2d5bc;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 1.8px;
  text-align: center;
}
.rank {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 78px;
  place-items: center;
  color: #fff8df;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(54px, 17vw, 84px);
  font-weight: 800;
  letter-spacing: -4px;
  line-height: .98;
  text-shadow: 0 2px 0 rgba(0,0,0,.45), 0 0 18px var(--glow), 0 0 30px color-mix(in srgb, var(--accent) 32%, transparent);
}
.rank.rank-up { animation: rank-flare-up 380ms cubic-bezier(.18,.82,.25,1) both; }
.rank.rank-down { animation: rank-flare-down 320ms ease-out both; }
@keyframes rank-flare-up {
  0% { transform: translateY(8px) scale(.9); filter: brightness(.8); }
  58% { transform: translateY(-4px) scale(1.08); filter: brightness(1.4); }
  100% { transform: translateY(0) scale(1); filter: brightness(1); }
}
@keyframes rank-flare-down {
  0% { transform: translateY(-3px) scale(1.04); filter: brightness(1.24); }
  100% { transform: translateY(0) scale(1); filter: brightness(1); }
}
.wins {
  position: relative;
  z-index: 1;
  padding-top: 7px;
  border-top: 1px solid rgba(237, 231, 196, .2);
  color: #c1cbbb;
  font-size: 10px;
  text-align: center;
}
.wins strong { margin: 0 2px; color: var(--accent-bright); font-size: 19px; font-variant-numeric: tabular-nums; }
.score-controls { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin-top: 9px; }
.score-controls button { min-width: 0; min-height: 54px; padding: 2px; font-size: 25px; }
.score-controls .minus { border-color: rgba(216, 224, 194, .23); color: #e1ead4; background: rgba(38, 54, 39, .94); }
.score-controls .plus {
  border-color: var(--accent-bright);
  color: #172319;
  background: linear-gradient(150deg, var(--accent-bright), var(--accent));
  box-shadow: 0 4px 13px var(--glow), inset 0 1px rgba(255,255,255,.55);
  font-size: 28px;
}
.ace-actions { position: relative; z-index: 1; display: grid; gap: 7px; margin-top: 9px; }
.ace-actions button { min-width: 0; min-height: 48px; padding: 8px 5px; font-size: 11px; line-height: 1.3; }
.win-button { border-color: #ffdc8b; color: #241b0c; background: linear-gradient(105deg, #ffe9a6, #ffad52); box-shadow: 0 4px 18px rgba(250, 183, 73, .24); }
.ace-actions button:not(.win-button) { border-color: rgba(185, 212, 185, .28); color: #e0e6d6; background: rgba(25, 48, 37, .92); }
.rule-hint {
  margin: 16px 0 0;
  color: #d3d9bd;
  font-size: 11px;
  line-height: 1.7;
  text-align: center;
}
.rule-hint::first-line { color: #f1d58c; font-weight: 800; letter-spacing: 1px; }
.toolbar { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; margin-top: 14px; }
.toolbar button { min-width: 0; min-height: 51px; padding: 7px 5px; color: #f3efd9; font-size: 12px; }
#undo:not(:disabled) { border-color: rgba(247, 211, 126, .39); color: #ffe8ad; background: linear-gradient(120deg, rgba(112, 77, 34, .54), rgba(31, 52, 38, .9)); }
.save-status { min-height: 17px; margin: 12px 0 0; color: #c7d5c0; font-size: 10px; text-align: center; font-variant-numeric: tabular-nums; }
.notice {
  margin: 12px 0 0;
  padding: 11px 13px;
  border: 1px solid rgba(255, 190, 126, .58);
  border-radius: 13px;
  color: #fff0d3;
  background: rgba(112, 54, 28, .72);
  font-size: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.result {
  position: relative;
  margin-top: 15px;
  padding: 15px;
  border: 1px solid rgba(255, 218, 128, .6);
  border-radius: 20px;
  background: radial-gradient(ellipse at 50% 0, rgba(255, 207, 102, .3), transparent 72%), rgba(50, 63, 37, .94);
  box-shadow: 0 0 26px rgba(255, 202, 93, .16);
  text-align: center;
}
.result p { margin: 0 0 12px; color: #fff0b7; font-size: 18px; font-weight: 900; overflow-wrap: anywhere; }
.primary { width: 100%; min-height: 52px; border-color: #ffdd8b; color: #241b0d; background: linear-gradient(110deg, #ffe9a8, #ffab51); }
footer { padding-top: 12px; color: #aab9a6; font-size: 9px; line-height: 1.6; text-align: center; }
footer p { margin: 5px 0; }
dialog {
  width: min(92vw, 470px);
  max-width: calc(100vw - 20px);
  max-height: min(86dvh, 760px);
  padding: 18px;
  overflow: auto;
  border: 1px solid rgba(240, 220, 155, .42);
  border-radius: 23px;
  color: #f5f1df;
  background: linear-gradient(145deg, #183428, #0a1a14 75%);
  box-shadow: 0 24px 90px rgba(0,0,0,.65), 0 0 28px rgba(239, 205, 119, .12);
}
dialog::backdrop { background: rgba(2, 12, 8, .73); backdrop-filter: blur(5px); }
.dialog-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
dialog .menu { display: grid; gap: 8px; }
dialog .menu button { min-height: 50px; padding: 10px 12px; text-align: left; overflow-wrap: anywhere; }
dialog p { color: #d5ddcc; font-size: 12px; line-height: 1.65; overflow-wrap: anywhere; }
dialog label { display: block; margin: 14px 0 8px; color: #e9dfb7; font-size: 13px; }
dialog input { width: 100%; min-height: 52px; padding: 12px; border: 1px solid rgba(221, 226, 193, .4); border-radius: 12px; color: #fff9e7; background: #081711; font-size: 16px; }
dialog form button[type="submit"] { margin-top: 18px; }
.dialog-actions { display: flex; gap: 9px; margin-top: 20px; }
.dialog-actions button { flex: 1 1 0; min-width: 0; min-height: 50px; padding: 7px; font-size: 12px; overflow-wrap: anywhere; }
.danger { color: #ffb495 !important; }
.history-list { padding-left: 23px; color: #f1e8ca; font-size: 12px; }
.history-list li { padding: 11px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.history-list span { display: block; margin-top: 5px; color: #c1cbbb; font-size: 11px; }
[hidden] { display: none !important; }

@media (max-width: 360px) {
  .app { padding-right: max(12px, env(safe-area-inset-right)); padding-left: max(12px, env(safe-area-inset-left)); }
  .teams { gap: 8px; }
  .team { padding: 8px; border-radius: 19px; }
  .team-heading { gap: 6px; }
  .team-crest { flex-basis: 36px; width: 36px; height: 36px; border-radius: 13px; font-size: 19px; }
  .team-name { min-height: 48px; font-size: 12px; }
  .team-name small { font-size: 9px; }
  .score-card { padding: 9px 6px 8px; border-radius: 14px; }
  .rank { min-height: 68px; font-size: clamp(48px, 16vw, 60px); }
  .score-controls { gap: 6px; }
  .score-controls button { min-height: 52px; }
  .round-bar { padding-inline: 10px; }
  .toolbar button { font-size: 11px; }
}
@media (max-height: 600px) and (orientation: portrait) {
  .app { padding-top: max(12px, env(safe-area-inset-top)); }
  .local-note { margin-block: 10px 12px; }
  .teams { padding-top: 11px; }
  .score-card { margin-top: 6px; }
  .rank { min-height: 65px; }
  .rule-hint { margin-top: 10px; }
  .toolbar { margin-top: 10px; }
  footer { padding-top: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  button:active:not(:disabled) { transform: none; }
}
