:root {
  color-scheme: light;
  font-family: "Noto Sans TC", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --blue-050: #f4f8ff;
  --blue-100: #e8f0ff;
  --blue-200: #d7e6ff;
  --blue-300: #bfd7ff;
  --blue-400: #8bb8ff;
  --blue-500: #5a92ff;
  --blue-600: #2f63ff;
  --blue-700: #1d45c4;
  --ink-900: #20304d;
  --ink-700: #4f5f7d;
  --line-soft: #d9e5fb;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100vh;
  overscroll-behavior: none;
}

body {
  display: grid;
  place-items: center;
  padding: clamp(8px, 2.6vw, 16px);
  background:
    radial-gradient(circle at top, rgba(160, 200, 255, 0.42), transparent 34%),
    linear-gradient(180deg, #eff5ff 0%, #eaf2ff 45%, #f6f9ff 100%);
  color: var(--ink-900);
}

body.interaction-locked {
  overflow: hidden;
  touch-action: none;
}

.app {
  width: 100%;
  max-width: 640px;
  max-height: 100dvh;
  padding: clamp(14px, 3.8vw, 24px);
  border-radius: 24px;
  border: 1px solid rgba(191, 215, 255, 0.9);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 40px rgba(55, 94, 170, 0.16);
  overflow: auto;
  backdrop-filter: blur(8px);
}

.brand {
  margin: 0 0 8px;
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--blue-600);
}

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

h1 {
  margin: 0 0 10px;
  font-size: clamp(1.6rem, 4vw, 1.95rem);
  line-height: 1.2;
  color: var(--blue-700);
}

.start-screen {
  margin: 0 0 16px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line-soft);
  background: linear-gradient(180deg, #ffffff 0%, var(--blue-050) 100%);
  text-align: center;
}

.start-screen-title {
  margin: 0 0 8px;
  color: var(--blue-700);
}

.start-screen-text {
  margin: 0 0 14px;
  color: var(--ink-700);
  line-height: 1.55;
}

.language-switcher {
  display: inline-flex;
  gap: 6px;
  flex-shrink: 0;
  padding: 6px;
  border-radius: 999px;
  background: var(--blue-050);
  border: 1px solid var(--line-soft);
}

.language-button {
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink-700);
  background: transparent;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.language-button.is-active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--blue-500) 0%, var(--blue-600) 100%);
  box-shadow: 0 8px 16px rgba(47, 99, 255, 0.22);
}

.intro {
  margin: 0 0 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--blue-050) 0%, #ffffff 100%);
  border: 1px solid var(--line-soft);
  line-height: 1.6;
  color: var(--ink-700);
}

.device-hint {
  margin: -4px 0 16px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid #ffd49f;
  background: #fff8ef;
  color: #8a4a00;
  line-height: 1.55;
  font-weight: 600;
}

.note-group + .note-group {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #dbe4f5;
}

.note-group h4 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: var(--ink-900);
}

.note-group ul {
  margin: 0;
  padding-left: 20px;
}

.note-group li + li {
  margin-top: 6px;
}

.note-highlight-text {
  margin: 12px 0 0;
  line-height: 1.6;
  font-weight: 600;
  color: #36507d;
}

.note-group--errors h4 {
  color: #1844c6;
}

.controls {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 16px;
}

.start-button {
  border: none;
  border-radius: 14px;
  min-height: 48px;
  padding: 10px 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 1rem;
  line-height: 1.2;
  font-weight: 800;
  background: linear-gradient(135deg, var(--blue-500) 0%, var(--blue-600) 100%);
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 12px 22px rgba(47, 99, 255, 0.24);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.start-button--hero {
  border-radius: 50%;
  width: clamp(92px, 24vw, 108px);
  height: clamp(92px, 24vw, 108px);
  padding: 0;
  margin-inline: auto;
}

.start-button:active {
  transform: translateY(1px) scale(0.99);
}

.start-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  box-shadow: none;
}

.countdown {
  display: grid;
  place-items: center;
  min-height: 280px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, var(--blue-050) 100%);
  border: 1px solid var(--line-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  margin-bottom: 16px;
  font-size: clamp(4rem, 18vw, 6rem);
  font-weight: 800;
  color: var(--blue-600);
  letter-spacing: 0.06em;
}

.grid {
  display: grid;
  width: 100%;
  touch-action: manipulation;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(6px, 1.9vw, 10px);
}

.cell {
  aspect-ratio: 1;
  color: var(--ink-900);
  border: 1px solid var(--blue-200);
  border-radius: clamp(12px, 3.4vw, 18px);
  display: grid;
  place-items: center;
  min-width: 0;
  font-size: clamp(0.96rem, 4vw, 1.45rem);
  font-weight: 700;
  background: linear-gradient(180deg, #ffffff 0%, #f6faff 100%);
  box-shadow: 0 8px 16px rgba(67, 104, 184, 0.1);
  cursor: pointer;
  user-select: none;
  transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.cell:active {
  transform: scale(0.97);
  box-shadow: 0 4px 10px rgba(67, 104, 184, 0.14);
}

@media (hover: hover) and (pointer: fine) {
  .cell:hover {
    transform: translateY(-1px);
  }
}

.cell.correct {
  background: linear-gradient(180deg, #dff6ea 0%, #d2efdf 100%);
  color: #21653d;
  border-color: #92d5ae;
  cursor: default;
  pointer-events: none;
  box-shadow: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none;
}

.result {
  margin: 16px 0 0;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid var(--blue-200);
  background: linear-gradient(180deg, #f6faff 0%, #edf4ff 100%);
  color: var(--blue-700);
}

.result-title {
  margin: 0 0 12px;
  font-size: 1.2rem;
}

.result-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.result-card {
  padding: 14px;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid var(--blue-200);
  box-shadow: 0 8px 18px rgba(74, 112, 184, 0.08);
}

.result-card-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.95rem;
  color: var(--ink-700);
}

.result-card-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--blue-700);
}

.result-guidance-title {
  margin: 0 0 12px;
  font-size: 1rem;
  color: var(--ink-900);
}

.result-guidance {
  margin: 0;
}

.note-group--result {
  padding: 16px;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid var(--line-soft);
}

.note-group--result + .note-group--result {
  margin-top: 12px;
}

.note-item--active {
  color: var(--blue-700);
  font-weight: 800;
  background: linear-gradient(180deg, #e8f0ff 0%, #dce9ff 100%);
  border: 1px solid var(--blue-200);
  border-radius: 12px;
  padding: 10px 12px;
  margin-left: -10px;
  margin-right: -10px;
  list-style-position: inside;
}

@media (max-width: 600px) {
  .app-header {
    flex-direction: column;
    align-items: stretch;
  }

  .language-switcher {
    align-self: flex-start;
  }
}

@media (max-width: 520px) {
  .app {
    border-radius: 20px;
  }

  .brand {
    font-size: 0.88rem;
  }

  h1 {
    font-size: clamp(1.35rem, 7vw, 1.7rem);
  }

  .intro {
    padding: 12px 14px;
  }

  .controls .start-button {
    width: fit-content;
    max-width: 100%;
  }

  .start-button--hero {
    width: clamp(92px, 30vw, 108px);
    height: clamp(92px, 30vw, 108px);
  }

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