
* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--background);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}


.page-wrap {
  width: min(100%, 1380px);
  min-height: 100svh;
  margin: 0 auto;
  padding: 30px 28px 24px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 13px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 15px;
  background: #174fb4;
  box-shadow: 0 8px 22px rgba(24, 89, 209, 0.24);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 760;
}

.brand-lockup strong,
.brand-lockup small {
  display: block;
}

.brand-lockup strong {
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.brand-lockup small {
  margin-top: 3px;
  color: var(--muted-foreground);
  font-size: .8rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  color: var(--foreground);
  cursor: pointer;
}

.hero-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin: 0 0 20px;
}

.eyebrow {
  color: var(--primary);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .13em;
}

.hero-row h1 {
  margin: 5px 0 5px;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1;
  letter-spacing: -0.055em;
}

.hero-row p {
  margin: 0;
  color: var(--muted-foreground);
}

.difficulty-card {
  min-width: 150px;
  padding: 13px 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  box-shadow: 0 10px 30px rgba(24, 47, 82, .06);
  text-align: right;
}

.difficulty-card span,
.difficulty-card small {
  display: block;
  color: var(--muted-foreground);
  font-size: .72rem;
}

.difficulty-card strong {
  display: inline-block;
  margin: 2px 0;
  font-size: 1.65rem;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: start;
}

.card {
  border: 1px solid var(--border);
  border-radius: 25px;
  background: color-mix(in srgb, var(--card) 94%, transparent);
  box-shadow: 0 16px 48px rgba(20, 44, 79, .08);
  backdrop-filter: blur(12px);
}

.game-card {
  padding: 18px;
}

.game-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 46px;
  margin-bottom: 14px;
}

.status-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--secondary);
  color: var(--secondary-foreground);
  font-size: .74rem;
  font-weight: 760;
}

.badge.highlight {
  background: #fff1c9;
  color: #805200;
}

.badge.motion {
  background: #e6eefc;
  color: #17489d;
}

.badge.select {
  background: #e7f7f3;
  color: #087361;
}

.badge.result {
  background: #e8f5e9;
  color: #26713a;
}

:root[data-theme="night"] .badge.highlight {
  background: #3d2e1d;
  color: #efc98f;
}

:root[data-theme="night"] .badge.motion {
  background: #222933;
  color: #aebbd0;
}

:root[data-theme="night"] .badge.select {
  background: #18342c;
  color: #87d4b8;
}

:root[data-theme="night"] .badge.result {
  background: #1d3325;
  color: #91d19d;
}

.phase-text {
  overflow: hidden;
  color: var(--muted-foreground);
  font-size: .84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timer-box {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.timer-box span {
  display: block;
  color: var(--muted-foreground);
  font-size: .62rem;
  letter-spacing: .12em;
}

.timer-box strong {
  font-size: 1.1rem;
}

.canvas-frame {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 300px;
  align-items: center;
  justify-content: center;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 12px;
  background:
    radial-gradient(circle at 35% 30%, rgba(24, 89, 209, .06), transparent 40%),
    color-mix(in srgb, var(--muted) 58%, var(--card));
}

#gameCanvas {
  display: block;
  max-width: none;
  flex-shrink: 0;
  height: auto;
  border: 1px solid color-mix(in srgb, var(--border) 80%, var(--foreground));
  border-radius: 14px;
  background:
    linear-gradient(rgba(87, 111, 145, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(87, 111, 145, .05) 1px, transparent 1px),
    color-mix(in srgb, var(--card) 94%, var(--background));
  background-size: 28px 28px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
  touch-action: manipulation;
}

.canvas-frame.selecting #gameCanvas {
  cursor: crosshair;
}

.canvas-overlay {
  position: absolute;
  display: grid;
  inset: 12px;
  place-content: center;
  border-radius: 14px;
  background: color-mix(in srgb, var(--card) 78%, transparent);
  backdrop-filter: blur(5px);
  text-align: center;
  pointer-events: none;
  transition: opacity .22s ease;
}

.canvas-overlay strong {
  font-size: 1.15rem;
}

.canvas-overlay span {
  margin-top: 6px;
  color: var(--muted-foreground);
  font-size: .82rem;
}

.canvas-overlay.hidden {
  opacity: 0;
  visibility: hidden;
}

.selection-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin: 13px 0 0;
  border-radius: 12px;
  padding: 9px 12px;
  background: var(--accent);
  color: var(--accent-foreground);
  font-size: .82rem;
}

.selection-hint span {
  margin-left: 5px;
  opacity: .75;
}

.result-panel {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px 22px;
  align-items: center;
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 15px 17px;
  background: color-mix(in srgb, var(--success-soft) 55%, var(--card));
}

.result-kicker {
  display: block;
  color: var(--muted-foreground);
  font-size: .7rem;
}

.result-panel #scoreValue {
  font-size: 2rem;
  line-height: 1;
}

.result-panel p {
  margin: 0;
  color: var(--muted-foreground);
  font-size: .85rem;
}

.legend {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  color: var(--muted-foreground);
  font-size: .75rem;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-ring {
  width: 13px;
  height: 13px;
  border: 3px solid;
  border-radius: 50%;
}

.legend-ring.correct {
  border-color: #25a978;
}

.legend-ring.selected {
  border-color: #377df0;
}

.legend-ring.wrong {
  border-color: #e14e60;
}

.game-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 13px;
  padding: 0 17px;
  cursor: pointer;
  font-weight: 720;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: .52;
}

.button.primary {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 8px 22px rgba(24, 89, 209, .22);
}

.button.success {
  background: var(--success);
  color: #fff;
}

:root[data-theme="night"] .button.success {
  color: #091813;
}

.button.ghost {

  
  border-color: var(--border);
  background: transparent;
  color: var(--muted-foreground);
}

.side-column {
  display: grid;
  gap: 18px;
}

.settings-card,
.records-card {
  padding: 18px;
}

.card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 15px;
}

.card-heading.compact {
  align-items: center;
}

.card-heading h2 {
  margin: 3px 0 0;
  font-size: 1.05rem;
}

.mini-status {
  border-radius: 999px;
  padding: 5px 8px;
  background: var(--secondary);
  color: var(--muted-foreground);
  font-size: .7rem;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
}

.field {
  display: grid;
  gap: 5px;
}

.field>span {
  color: var(--muted-foreground);
  font-size: .74rem;
}

.field input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--input);
  border-radius: 10px;
  outline: none;
  padding: 0 10px;
  background: var(--card);
  color: var(--foreground);
  font-variant-numeric: tabular-nums;
}

.field input:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 17%, transparent);
}

.field input:disabled {
  background: var(--muted);
  color: var(--muted-foreground);
  opacity: .7;
}

.input-unit {
  position: relative;
}

.input-unit input {
  padding-right: 30px;
}

.input-unit b {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  font-size: .7rem;
  font-weight: 600;
  pointer-events: none;
}

.difficulty-explainer {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.difficulty-explainer>span {
  color: var(--muted-foreground);
  font-size: .72rem;
}

.difficulty-track {
  height: 7px;
  margin: 7px 0 8px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--secondary);
}

.difficulty-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #31b79a, #4d7fe9, #b45dd7);
  transition: width .2s ease;
}

.difficulty-explainer p {
  margin: 0;
  color: var(--muted-foreground);
  font-size: .7rem;
  line-height: 1.55;
}

.text-button {
  border: 0;
  padding: 4px 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font-size: .74rem;
  font-weight: 700;
}

.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 11px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--border);
  font-size: .75rem;
}

.player-row span {
  color: var(--muted-foreground);
}

.player-row strong {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.records-list {
  display: grid;
  gap: 8px;
  max-height: 285px;
  overflow-y: auto;
}

.record-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 9px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 10px;
  background: color-mix(in srgb, var(--muted) 45%, transparent);
}

.record-score {
  display: grid;
  width: 45px;
  height: 45px;
  place-items: center;
  border-radius: 12px;
  background: var(--card);
  color: var(--primary);
  font-size: .78rem;
  font-weight: 800;
}

.record-main strong,
.record-main small {
  display: block;
}

.record-main strong {
  font-size: .77rem;
}

.record-main small {
  margin-top: 3px;
  color: var(--muted-foreground);
  font-size: .66rem;
}

.record-difficulty {
  text-align: right;
}

.record-difficulty strong {
  display: block;
  font-size: .76rem;
}

.record-difficulty small {
  color: var(--muted-foreground);
  font-size: .64rem;
}

.empty-state {
  margin: 12px 0;
  color: var(--muted-foreground);
  font-size: .78rem;
  text-align: center;
}

.page-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 18px;
  padding: 10px 3px 0;
  color: var(--muted-foreground);
  font-size: .72rem;
}

.page-footer a {
  text-decoration: none;
}

.page-footer a:hover {
  color: var(--foreground);
}

.hidden {
  display: none !important;
}

@media (max-width: 1000px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .side-column {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .page-wrap {
    padding: 18px 14px 20px;
  }

  .app-header {
    align-items: flex-start;
  }

  .hero-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 13px;
  }

  .difficulty-card {
    width: 100%;
    text-align: left;
  }

  .side-column {
    grid-template-columns: 1fr;
  }

  .field-grid {
    grid-template-columns: 1fr 1fr;
  }

  .phase-text {
    display: none;
  }

  .result-panel {
    grid-template-columns: 1fr;
  }

  .legend {
    grid-column: 1;
  }
}

@media (max-width: 470px) {
  .brand-lockup small {
    display: none;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .game-toolbar {
    align-items: flex-start;
  }

  .status-group {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .game-actions {
    flex-wrap: wrap;
  }

  .button {
    flex: 1 1 auto;
  }
}

/* Paper Style */

:root[data-theme="paper"] .brand-mark {
  background: #703d2d;
  box-shadow: 0 8px 22px rgba(112, 61, 45, 0.20);
}

:root[data-theme="paper"] .card,
:root[data-theme="paper"] .difficulty-card {
  border-color: rgba(29, 28, 24, 0.12);

  background: rgba(255, 255, 255, 0.58);

  box-shadow:
    0 14px 40px rgba(54, 47, 35, 0.07);

  backdrop-filter: blur(14px);
}

:root[data-theme="paper"] .hero-row h1 {
  font-weight: 500;
  letter-spacing: -0.035em;
}

:root[data-theme="paper"] .eyebrow {
  color: #703d2d;
}

:root[data-theme="paper"] .canvas-frame {
  background:
    radial-gradient(circle at 30% 25%,
      rgba(156, 116, 80, 0.07),
      transparent 44%),
    rgba(255, 255, 255, 0.32);
}

:root[data-theme="paper"] #gameCanvas {
  border-color: rgba(29, 28, 24, 0.18);

  background:
    linear-gradient(rgba(86, 72, 57, 0.045) 1px,
      transparent 1px),
    linear-gradient(90deg,
      rgba(86, 72, 57, 0.045) 1px,
      transparent 1px),
    #f8f5ee;

  background-size: 28px 28px;

  box-shadow:
    inset 0 0 26px rgba(98, 76, 53, 0.035);
}

:root[data-theme="paper"] .button.primary {
  box-shadow:
    0 8px 22px rgba(112, 61, 45, 0.18);
}

:root[data-theme="paper"] .difficulty-track i {
  background:
    linear-gradient(90deg,
      #738d7d,
      #9c7450,
      #703d2d);
}


/* Night Style */

:root[data-theme="night"] .brand-mark {
  background: #2a211b;
  border: 1px solid #574435;

  color: #e5bd91;

  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.36);
}

:root[data-theme="night"] .card,
:root[data-theme="night"] .difficulty-card {
  background:
    color-mix(in srgb,
      var(--card) 94%,
      transparent);

  box-shadow:
    0 22px 60px rgba(0, 0, 0, 0.28);
}

:root[data-theme="night"] .canvas-frame {
  background:
    radial-gradient(circle at 40% 28%,
      rgba(210, 160, 110, 0.045),
      transparent 45%),
    #0e1115;
}

:root[data-theme="night"] #gameCanvas {
  border-color: #34383f;

  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px,
      transparent 1px),
    linear-gradient(90deg,
      rgba(255, 255, 255, 0.025) 1px,
      transparent 1px),
    #101318;

  background-size: 28px 28px;
}

:root[data-theme="night"] .difficulty-track i {
  background:
    linear-gradient(90deg,
      #629b88,
      #c28e60,
      #d2a06e);
}


/* button */
.theme-button {
  width: auto;
  min-width: 76px;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;

  padding: 0 11px;

  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.theme-button:hover {
  transform: translateY(-1px);
}

#themeIcon {
  font-size: 14px;
}

#themeLabel {
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

#canvasFrame {
  position: relative;
}

.countdown-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;

  display: flex;
  align-items: center;
  justify-content: center;

  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);

  pointer-events: none;
}

.countdown-overlay.hidden {
  display: none;
}

.countdown-number {
  min-width: 120px;
  height: 120px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 28px;

  background: rgba(20, 20, 20, 0.88);
  color: white;

  font-size: 64px;
  font-weight: 800;
  line-height: 1;

  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.22);

  transform: scale(1);
  animation: countdownPop 0.55s ease;
}

@keyframes countdownPop {
  0% {
    transform: scale(0.75);
    opacity: 0;
  }

  25% {
    transform: scale(1.08);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@media (max-width: 720px) {
  .page-wrap {
    width: 100%;
    padding: 16px 14px 20px;
  }

  /* 顶部彻底改成两行布局 */
  .app-header {
    display: grid;
    grid-template-columns: 1fr auto;
    width: 100%;
    align-items: center;
    gap: 14px 10px;
    margin-bottom: 24px;
  }

  .brand-lockup {
    grid-column: 1 / -1;

    width: 100%;
    min-width: 0;

    justify-content: flex-start;
  }

  .brand-lockup>span:last-child {
    min-width: 0;
    flex: 1;
  }

  .brand-lockup strong,
  .brand-lockup small {
    width: 100%;
  }

  .header-actions {
    grid-column: 1 / -1;

    width: 100%;
    min-width: 0;

    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  /* Ball Attention 标题区域必须占满屏幕 */
  .hero-row {
    display: block;
    width: 100%;
    margin-bottom: 18px;
  }

  .hero-row>div:first-child {
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .hero-row h1 {
    width: 100%;
    max-width: none;

    font-size: clamp(2.15rem, 12vw, 3.2rem);
    line-height: 1;
  }

  .hero-row p {
    width: 100%;
    max-width: none;
    margin-top: 7px;
    line-height: 1.5;
  }

  .difficulty-card {
    width: 100%;
    margin-top: 14px;
    text-align: left;
  }

  .game-layout {
    width: 100%;
    grid-template-columns: minmax(0, 1fr);
  }

  .side-column {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .field-grid {
    grid-template-columns: 1fr 1fr;
  }

  .phase-text {
    display: none;
  }

  .result-panel {
    grid-template-columns: 1fr;
  }

  .legend {
    grid-column: 1;
  }
}

.settings-import {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.settings-import input {
  flex: 1;
  min-width: 0;
}

.settings-import button {
  flex: 0 0 auto;
}

@media (max-width: 520px) {
  .settings-import {
    flex-direction: column;
  }

  .settings-import button {
    width: 100%;
  }
}


.header-link {
  height: 38px;
  min-height: 38px;
  padding: 0 12px;

  display: inline-flex;
  align-items: center;

  border: 1px solid var(--border);
  border-radius: 12px;

  background: color-mix(in srgb,
      var(--card) 88%,
      transparent);

  color: var(--foreground);
  text-decoration: none;

  font-size: .75rem;
  font-weight: 650;
  white-space: nowrap;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.header-link:hover {
  transform: translateY(-1px);
}