* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", system-ui, sans-serif;
  --ink: #231f20;
  --paper: #fffaf2;
  --canvas: #f5efe5;
  --accent: #f97316;
  --muted: #746d66;
  --success: #15803d;
  --skip: #57534e;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 8%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 28rem),
    var(--canvas);
  transition: background 180ms ease;
  -webkit-tap-highlight-color: transparent;
}

button,
select,
input {
  font: inherit;
}

button,
select {
  min-height: 3rem;
}

button {
  cursor: pointer;
}

.settings-button,
.settings-close {
  display: grid;
  flex: 0 0 auto;
  width: 3rem;
  min-height: 3rem;
  padding: 0;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  color: var(--ink);
  background: var(--paper);
  font-size: 1.25rem;
  font-weight: 900;
}

.settings-icon {
  width: 1.35rem;
  height: 1.35rem;
  fill: currentColor;
}


[hidden] {
  display: none !important;
}

.app-shell {
  width: min(100%, 44rem);
  min-height: 100dvh;
  margin: 0 auto;
}

.screen {
  min-height: 100dvh;
  padding: max(1.25rem, env(safe-area-inset-top)) 1.25rem max(1.5rem, env(safe-area-inset-bottom));
}


.brand,
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
}

.brand {
  justify-content: flex-start;
  margin: 0.6rem 0 2rem;
}

.brand .settings-button {
  margin-left: auto;
}

.brand-mark {
  display: grid;
  width: 3.4rem;
  border: 0;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 1rem;
  color: white;
  background: var(--ink);
  font-size: 1.45rem;
  font-weight: 950;
  transform: rotate(-7deg);
  box-shadow: 0.3rem 0.35rem 0 var(--accent);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.1rem, 10vw, 3.2rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
}

h2 {
  margin-bottom: 0.7rem;
  font-size: clamp(2rem, 9vw, 3rem);
  line-height: 1;
  letter-spacing: -0.045em;
}

.eyebrow,
.kicker {
  margin-bottom: 0.35rem;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.setup-card {
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 2rem;
  background: var(--paper);
  box-shadow: 0.65rem 0.7rem 0 var(--ink);
}

.setup-intro,
#setup-form {
  padding: 1.5rem;
}

.setup-intro {
  padding-bottom: 1.1rem;
  border-bottom: 2px solid var(--ink);
}

.setup-intro p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

#setup-form {
  display: grid;
  gap: 1.15rem;
}

#setup-form > label,
legend {
  margin-bottom: -0.65rem;
  font-size: 0.82rem;
  font-weight: 850;
}

select {
  width: 100%;
  height: 3.5rem;
  padding: 0 1rem;
  border: 2px solid var(--ink);
  border-radius: 0.9rem;
  color: var(--ink);
  background: white;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 0.5rem;
}

.duration-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.duration-options label {
  position: relative;
}

.duration-options input {
  position: absolute;
  opacity: 0;
}

.duration-options span {
  display: grid;
  min-height: 3rem;
  place-items: center;
  border: 2px solid #d8d0c7;
  border-radius: 0.85rem;
  background: white;
  font-weight: 850;
}

.duration-options input:checked + span {
  border-color: var(--ink);
  color: white;
  background: var(--ink);
  box-shadow: inset 0 -0.2rem 0 color-mix(in srgb, var(--accent) 80%, black);
}

.primary-button,
.action-button {
  border: 2px solid var(--ink);
  border-radius: 1rem;
  font-weight: 900;
}

.primary-button {
  width: 100%;
  padding: 0.95rem 1.2rem;
  color: white;
  background: var(--ink);
  box-shadow: 0 0.3rem 0 var(--accent);
}

.primary-button:active,
.action-button:active {
  transform: translateY(0.15rem);
  box-shadow: none;
}

.game-screen {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 0.85rem;
  overflow: hidden;
}

.game-header {
  display: grid;
  min-height: 3.5rem;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.45rem;
}

.game-header .settings-button {
  width: 2.6rem;
  min-height: 2.6rem;
  justify-self: end;
}



.timer {
  display: flex;
  grid-column: 2;
  align-items: baseline;
  font-variant-numeric: tabular-nums;
  font-weight: 950;
}

.timer span {
  min-width: 4ch;
  font-size: 2.65rem;
  line-height: 1;
  text-align: right;
  letter-spacing: -0.07em;
}


.timer.urgent {
  color: #b91c1c;
  animation: pulse 700ms ease-in-out infinite alternate;
}

.swipe-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 750;
  text-align: center;
}

.card-stage {
  display: grid;
  min-height: 0;
  place-items: center;
  perspective: 900px;
}

.game-card {
  position: relative;
  width: min(100%, 38rem);
  min-height: min(29rem, 57dvh);
  touch-action: pan-y;
  user-select: none;
  will-change: transform, opacity;
}

.game-card.enter {
  animation: draw-card 320ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.game-card.exit-correct {
  animation: throw-right 260ms ease-in both;
}

.game-card.exit-skip {
  animation: throw-left 260ms ease-in both;
}

.card-age {
  font-size: 0.73rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.target-word {
  display: block;
  width: 100%;
  overflow: hidden;
  font-size: clamp(2.2rem, 10vw, 5rem);
  font-weight: 950;
  line-height: 1;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.forbidden-words {
  margin: 0;
  padding: 0;
  list-style: none;
}

.card-classic {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 1.1rem;
  padding: 1.45rem;
  border: 3px solid var(--ink);
  border-radius: 1.8rem;
  background: var(--paper);
  box-shadow:
    0.5rem 0.55rem 0 var(--ink),
    0.95rem 1rem 0 color-mix(in srgb, var(--accent) 55%, white);
}

.card-classic .card-age {
  justify-self: start;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  color: white;
  background: var(--accent);
}

.card-classic .target-word {
  padding-bottom: 1rem;
  border-bottom: 3px solid var(--accent);
}

.card-classic .forbidden-words {
  display: grid;
  align-content: center;
  gap: 0.6rem;
}

.card-classic .forbidden-words li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: clamp(1.25rem, 6vw, 2.35rem);
  font-weight: 800;
}

.card-classic .forbidden-words li::before {
  content: "×";
  display: grid;
  width: 1.4em;
  aspect-ratio: 1;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--accent);
  font-size: 0.55em;
}

.card-footer {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}


.game-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
}

.action-button {
  padding: 0.8rem;
  background: var(--paper);
  box-shadow: 0 0.25rem 0 var(--ink);
}

.skip-button {
  padding: 0.8rem 1.4rem;
  color: var(--skip);
}

.correct-button {
  color: white;
  background: var(--success);
}

.summary-screen {
  position: relative;
  display: grid;
  align-content: center;
  gap: 1.1rem;
}

.summary-settings {
  position: absolute;
  top: max(1.25rem, env(safe-area-inset-top));
  right: 1.25rem;
}

.summary-header {
  text-align: center;
}

.final-score {
  margin-bottom: 0;
  color: var(--muted);
}

.final-score strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--accent);
  font-size: 5rem;
  line-height: 0.95;
}

.result-lists {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.result-lists section {
  min-height: 9rem;
  padding: 1rem;
  border: 2px solid var(--ink);
  border-radius: 1.2rem;
  background: var(--paper);
}

.result-lists h3 {
  margin-bottom: 0.7rem;
  font-size: 0.92rem;
}

.result-lists ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.result-lists .empty-result {
  list-style: none;
  margin-left: -1.1rem;
}


dialog {
  width: min(calc(100% - 2rem), 28rem);
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 1.5rem;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0.65rem 0.7rem 0 var(--ink);
}

dialog::backdrop {
  background: rgb(35 31 32 / 55%);
}

.settings-panel {
  display: grid;
  gap: 1.25rem;
  padding: 1.5rem;
}

.settings-header,
.setting-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.settings-header h2,
.settings-header p {
  margin-bottom: 0;
}

.audio-setting {
  display: grid;
  gap: 0.65rem;
}

.setting-heading > label:first-child {
  font-weight: 900;
}

.audio-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 800;
}

.audio-toggle input,
.audio-setting input[type="range"] {
  accent-color: var(--accent);
}

.audio-setting input[type="range"] {
  width: 100%;
}

.abort-round-button {
  width: 100%;
  min-height: 3rem;
  border: 2px solid #b91c1c;
  border-radius: 0.9rem;
  color: #b91c1c;
  background: transparent;
  font-weight: 900;
}
@keyframes draw-card {
  from {
    opacity: 0;
    transform: translateY(-2.5rem) scale(0.92);
  }
  to {
    opacity: 1;
  }
}

@keyframes throw-right {
  to {
    opacity: 0;
    transform: translateX(125%);
  }
}

@keyframes throw-left {
  to {
    opacity: 0;
    transform: translateX(-125%);
  }
}

@keyframes pulse {
  to {
    transform: scale(1.08);
  }
}

:focus-visible {
  outline: 4px solid color-mix(in srgb, var(--accent) 80%, white);
  outline-offset: 3px;
}

@media (max-height: 700px) {
  .game-card {
    min-height: 24rem;
  }

  .card-classic {
    gap: 0.7rem;
  }

  .card-classic .forbidden-words {
    gap: 0.35rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
