/* MatPro v1.6.0 modern UI styles */
:root {
  --bg: #f6f8fc;
  --bg-wash: #eaf7f8;
  --surface: #ffffff;
  --surface-soft: #eef6ff;
  --surface-strong: #dff7f3;
  --text: #162033;
  --muted: #64748b;
  --soft: #f8fafc;
  --brand: #0ea5e9;
  --brand-strong: #2563eb;
  --mint: #14b8a6;
  --orange: #f97316;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #ef4444;
  --border: rgba(15, 23, 42, 0.12);
  --shadow: 0 22px 70px rgba(15, 23, 42, 0.14);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(14, 165, 233, .10), transparent 34%),
    linear-gradient(225deg, rgba(20, 184, 166, .13), transparent 42%),
    linear-gradient(180deg, var(--bg), var(--bg-wash));
  color: var(--text);
}

body.modal-open {
  overflow: hidden;
}

button, input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible, input:focus-visible {
  outline: 3px solid rgba(14, 165, 233, .35);
  outline-offset: 3px;
}

.hidden { display: none !important; }

.app {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 54px;
}

.topbar {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(255, 255, 255, .86);
  box-shadow: 0 14px 40px rgba(15, 23, 42, .10);
  backdrop-filter: blur(18px);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.logo {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  color: white;
  background: linear-gradient(135deg, var(--brand-strong), var(--mint));
  box-shadow: 0 12px 30px rgba(37, 99, 235, .22);
  font-weight: 1000;
}

.brand-title {
  min-width: 0;
  line-height: 1.06;
}

.brand-title strong {
  display: block;
  font-size: 1.04rem;
  letter-spacing: 0;
}

.brand-title span {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 52vw;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-link-btn {
  min-height: 42px;
  padding: 0 13px;
  border-radius: 999px;
  color: var(--brand-strong);
  background: rgba(14, 165, 233, .10);
  border: 1px solid rgba(14, 165, 233, .22);
  font-size: .86rem;
  font-weight: 1000;
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, .72);
  font-weight: 800;
  font-size: .88rem;
  white-space: nowrap;
}

.lang-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(44px, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(14, 165, 233, .22);
  border-radius: 999px;
  background: rgba(14, 165, 233, .10);
  white-space: nowrap;
}

.lang-switch button {
  min-height: 36px;
  padding: 0 11px;
  border-radius: 999px;
  color: var(--brand-strong);
  background: transparent;
  font-weight: 1000;
  font-size: .82rem;
}

.lang-switch button.active {
  color: white;
  background: linear-gradient(135deg, var(--brand-strong), var(--mint));
  box-shadow: 0 8px 20px rgba(37, 99, 235, .20);
}

.app-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
  color: var(--muted);
}

.app-footer a,
.app-footer span,
.app-footer button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, .70);
  font-size: .88rem;
  font-weight: 900;
  text-decoration: none;
}

.app-footer a,
.app-footer button {
  color: var(--brand-strong);
}

.screen {
  margin-top: 22px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, .88);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.language-panel {
  width: min(660px, 100%);
  margin: clamp(28px, 8vh, 86px) auto 0;
  padding: clamp(24px, 5vw, 44px);
  text-align: center;
}

.language-panel h1,
.hero-panel h1,
.card-header h2,
.result-title {
  margin: 0;
  letter-spacing: 0;
  line-height: .98;
}

.language-panel h1 {
  font-size: clamp(3rem, 8vw, 68px);
}

.language-panel p,
.hero-panel p,
.card-header p,
.result-note {
  color: var(--muted);
  line-height: 1.6;
}

.language-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 26px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  border-radius: 18px;
  padding: 14px 18px;
  color: var(--text);
  background: var(--surface-soft);
  font-weight: 900;
  text-decoration: none;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  color: white;
  background: linear-gradient(135deg, var(--brand-strong), var(--mint));
  box-shadow: 0 16px 34px rgba(37, 99, 235, .22);
}

.btn-secondary {
  color: var(--brand-strong);
  background: rgba(14, 165, 233, .10);
  border: 1px solid rgba(14, 165, 233, .18);
}

.btn-danger {
  color: white;
  background: var(--danger);
}

.btn-muted {
  color: var(--text);
  background: #e2e8f0;
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(330px, .92fr);
  gap: 20px;
  align-items: stretch;
}

.home-side {
  display: grid;
  gap: 20px;
  align-content: start;
}

.hero-panel {
  padding: clamp(24px, 4vw, 44px);
  display: grid;
  align-content: space-between;
  min-height: 520px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.94), rgba(255,255,255,.82)),
    linear-gradient(135deg, rgba(14,165,233,.14), rgba(20,184,166,.12));
}

.eyebrow {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  color: #075985;
  background: rgba(14, 165, 233, .12);
  border: 1px solid rgba(14, 165, 233, .20);
  font-size: .84rem;
  font-weight: 900;
}

.hero-panel h1 {
  max-width: 700px;
  margin-top: 18px;
  font-size: clamp(48px, 8vw, 96px);
}

.gradient-text {
  background: linear-gradient(120deg, var(--brand-strong), var(--mint), var(--orange));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 34px;
}

.mini-stat,
.method-note,
.field,
.expert-note,
.review-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, .72);
}

.mini-stat {
  padding: 16px;
}

.mini-stat strong {
  display: block;
  font-size: 1.45rem;
  letter-spacing: 0;
}

.mini-stat span {
  color: var(--muted);
  font-weight: 700;
  font-size: .86rem;
}

.method-note {
  margin-top: 18px;
  padding: 16px;
  color: var(--muted);
  line-height: 1.55;
  background: rgba(223, 247, 243, .70);
}

.method-note strong {
  display: block;
  color: var(--text);
  margin-bottom: 5px;
}

.active-practice-panel {
  padding: 24px;
}

.active-practice-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.active-practice-head h2 {
  margin: 0;
  font-size: clamp(1.45rem, 4vw, 2.1rem);
  letter-spacing: 0;
}

.active-practice-head p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.quick-practice-card {
  margin-top: 20px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.quick-practice-problem {
  margin: 18px 0 20px;
  text-align: center;
  color: var(--brand-strong);
  font-size: clamp(56px, 12vw, 86px);
  line-height: .95;
  font-weight: 1000;
  letter-spacing: 0;
}

.quick-practice-dock {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.quick-feedback {
  min-height: 44px;
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 16px;
  font-weight: 900;
  line-height: 1.4;
}

.quick-feedback:empty {
  display: none;
}

.quick-feedback.correct {
  color: #166534;
  border-color: rgba(22, 163, 74, .24);
  background: rgba(22, 163, 74, .10);
}

.quick-feedback.wrong {
  color: #991b1b;
  border-color: rgba(239, 68, 68, .24);
  background: rgba(239, 68, 68, .10);
}

.quick-feedback.empty {
  color: #92400e;
  border-color: rgba(245, 158, 11, .26);
  background: rgba(245, 158, 11, .12);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 24px 0;
}

.card-header h2 {
  font-size: clamp(1.4rem, 4vw, 2rem);
}

.ranking-list,
.config-grid,
.result-grid {
  display: grid;
  gap: 14px;
  padding: 24px;
}

.ranking-actions {
  padding-top: 0;
}

.rank-item {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  color: var(--text);
  background: rgba(248, 250, 252, .86);
  text-align: left;
}

.rank-place {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 15px;
  color: white;
  background: linear-gradient(135deg, var(--brand-strong), var(--mint));
  font-weight: 1000;
}

.rank-name {
  min-width: 0;
}

.rank-name strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0;
}

.rank-name span {
  display: block;
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.4;
}

.rank-name .rank-meta {
  color: var(--text);
  font-weight: 800;
}

.rank-name .rank-config {
  margin-top: 3px;
}

.grade {
  display: grid;
  place-items: center;
  min-width: 54px;
  height: 54px;
  padding: 0 9px;
  border-radius: 18px;
  color: white;
  background: var(--text);
  font-weight: 1000;
}

.grade small {
  display: block;
  font-size: .68rem;
  opacity: .78;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 18px;
  color: var(--muted);
  background: rgba(248, 250, 252, .72);
  line-height: 1.55;
}

.config-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(290px, .62fr);
  gap: 20px;
  align-items: start;
}

.section-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: .76rem;
  font-weight: 1000;
  margin-bottom: 10px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.segmented.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.segment,
.table-chip {
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text);
  background: rgba(248, 250, 252, .88);
  font-weight: 900;
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}

.segment.active,
.table-chip.active {
  color: white;
  border-color: transparent;
  background: linear-gradient(135deg, var(--brand-strong), var(--mint));
  box-shadow: 0 12px 28px rgba(37, 99, 235, .18);
}

.segment:hover,
.table-chip:hover {
  transform: translateY(-1px);
}

.expert-note {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  color: #92400e;
  background: rgba(245, 158, 11, .12);
  border-color: rgba(245, 158, 11, .26);
  line-height: 1.5;
}

.smart-practice-note {
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px solid rgba(14, 165, 233, .20);
  border-radius: 18px;
  color: var(--muted);
  background: rgba(14, 165, 233, .08);
  line-height: 1.5;
}

.smart-practice-note strong {
  color: var(--text);
  font-size: 1.05rem;
}

.sliders {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  padding: 16px;
  background: rgba(248, 250, 252, .86);
}

.field label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-weight: 800;
}

.field strong {
  color: var(--text);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--brand);
}

.tables-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 9px;
}

.table-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.table-warning {
  margin-top: 10px;
}

.field-hint {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
  line-height: 1.35;
}

.btn:disabled {
  opacity: .48;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.preview-card {
  padding: 24px;
}

.preview-phone {
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 14px;
  background: linear-gradient(180deg, #ffffff, #edf7ff);
  box-shadow: 0 18px 50px rgba(15, 23, 42, .12);
}

.preview-screen {
  border-radius: 22px;
  padding: 16px;
  background: #f8fafc;
  border: 1px solid var(--border);
}

.preview-problem {
  margin: 18px 0;
  text-align: center;
  font-size: clamp(48px, 10vw, 72px);
  line-height: .95;
  font-weight: 1000;
  letter-spacing: 0;
}

.preview-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.preview-options span {
  display: grid;
  place-items: center;
  min-height: 48px;
  border-radius: 16px;
  color: var(--text);
  background: white;
  border: 1px solid var(--border);
  font-weight: 1000;
}

.preview-options span.active {
  color: white;
  background: linear-gradient(135deg, var(--brand-strong), var(--mint));
  border-color: transparent;
}

.game-panel {
  width: min(760px, 100%);
  margin: 22px auto 0;
  padding: clamp(18px, 4vw, 28px);
  position: relative;
}

.game-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.game-meta {
  min-width: 0;
  text-align: center;
  color: var(--muted);
  font-weight: 800;
}

.game-meta strong {
  display: block;
  color: var(--text);
  font-size: 1.05rem;
}

.timer-track {
  width: 100%;
  height: 13px;
  margin: 18px 0 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

#timer-bar {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint), var(--brand), var(--orange));
}

.question-card {
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: clamp(20px, 5vw, 34px);
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  text-align: center;
}

#question {
  font-size: clamp(72px, 18vw, 128px);
  line-height: .9;
  margin: 12px 0 22px;
  font-weight: 1000;
  letter-spacing: 0;
  color: var(--brand-strong);
}

#quick-answer-input,
#player-name-input {
  width: 100%;
  min-height: 56px;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 0 16px;
  color: var(--text);
  background: #f8fafc;
  font-weight: 900;
  font-size: 1.08rem;
}

#quick-answer-input {
  text-align: center;
  font-size: 1.4rem;
}

.choice-grid {
  display: grid;
  gap: 10px;
}

.option-btn {
  min-height: 54px;
  border-radius: 17px;
  color: var(--text);
  background: #edf6ff;
  border: 1px solid rgba(14, 165, 233, .16);
  font-size: 1.12rem;
  font-weight: 1000;
}

.choice-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.option-btn {
  min-height: 72px;
  color: white;
  background: linear-gradient(135deg, var(--orange), #fb7185);
  border-color: transparent;
  font-size: clamp(1.3rem, 6vw, 2rem);
}

.timer-pill {
  margin: auto;
}

.live-review {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 16px 2px 2px;
  scrollbar-width: none;
}

.live-review::-webkit-scrollbar { display: none; }

.bubble {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 14px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: #f8fafc;
  font-size: .88rem;
  font-weight: 1000;
}

.bubble.current {
  color: var(--brand-strong);
  border-color: rgba(14, 165, 233, .32);
  background: rgba(14, 165, 233, .10);
}

.bubble.ok {
  color: white;
  background: var(--success);
  border-color: transparent;
}

.bubble.bad {
  color: white;
  background: var(--danger);
  border-color: transparent;
}

.bubble.skip {
  color: white;
  background: var(--warning);
  border-color: transparent;
}

.cancel-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(12px);
}

.cancel-card {
  width: min(440px, 100%);
  padding: 24px;
  border-radius: 24px;
  background: white;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-align: center;
}

.cancel-card h2 {
  margin: 0 0 8px;
  letter-spacing: 0;
}

#cancel-timer {
  color: var(--danger);
  font-size: 2rem;
  font-weight: 1000;
}

.result-grid {
  grid-template-columns: .82fr 1.18fr;
  align-items: stretch;
}

.score-panel {
  display: grid;
  place-items: center;
  padding: 28px;
  text-align: center;
}

.grade-ring {
  --score-pct: 0%;
  display: grid;
  place-items: center;
  width: min(220px, 64vw);
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--success) var(--score-pct), #e2e8f0 0);
  position: relative;
  box-shadow: inset 0 0 0 1px var(--border), 0 20px 54px rgba(22, 163, 74, .16);
}

.grade-ring::after {
  content: "";
  position: absolute;
  inset: 16px;
  border-radius: 50%;
  background: white;
  border: 1px solid var(--border);
}

.grade-ring span {
  position: relative;
  z-index: 1;
  font-size: clamp(40px, 12vw, 64px);
  font-weight: 1000;
  letter-spacing: 0;
}

.result-title {
  font-size: clamp(2rem, 7vw, 44px);
}

.res-card {
  display: grid;
  gap: 8px;
  border-radius: 22px;
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 14px;
}

.res-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 9px 4px;
  border-bottom: 1px solid rgba(15, 23, 42, .08);
  color: var(--muted);
  font-weight: 800;
}

.res-row:last-child {
  border-bottom: 0;
}

.res-row strong,
.res-row span:last-child {
  color: var(--text);
}

.scroll-subwindow {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #f8fafc;
  padding: 10px;
}

.review-item {
  padding: 12px;
  margin-bottom: 8px;
  line-height: 1.45;
}

.history-summary {
  border-left: 5px solid var(--brand);
  background: white;
}

.history-summary span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.history-review-title {
  margin: 6px 0 8px;
}

.review-item:last-child { margin-bottom: 0; }
.rev-wrong { border-left: 5px solid var(--danger); }
.rev-skipped { border-left: 5px solid var(--warning); }
.rev-correct { border-left: 5px solid var(--success); }

.result-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, .34);
  backdrop-filter: blur(10px);
}

.modal-card {
  width: min(100%, 980px);
  max-height: min(860px, calc(100vh - 36px));
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 28px 90px rgba(15, 23, 42, .24);
  padding: clamp(20px, 4vw, 34px);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.modal-head h2 {
  margin: 14px 0 10px;
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 1;
  letter-spacing: 0;
}

.modal-head p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.modal-close {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--text);
  background: #e2e8f0;
  font-weight: 1000;
}

.guide-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 24px 0;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.guide-section {
  display: grid;
  gap: 12px;
}

.guide-wide {
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.guide-wide h3 {
  grid-column: 1 / -1;
}

.guide-section h3 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: 0;
}

.guide-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #f8fafc;
  line-height: 1.5;
}

.guide-card span {
  display: inline-grid;
  place-items: center;
  min-width: 38px;
  height: 32px;
  margin-bottom: 12px;
  padding: 0 8px;
  border-radius: 999px;
  color: white;
  background: linear-gradient(135deg, var(--brand-strong), var(--mint));
  font-size: .78rem;
  font-weight: 1000;
}

.guide-card strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 1rem;
}

.guide-card p,
.about-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.about-card {
  width: min(100%, 780px);
}

.about-copy {
  display: grid;
  gap: 14px;
  margin-top: 12px;
}

.about-copy strong {
  display: block;
  padding: 16px;
  border: 1px solid rgba(20, 184, 166, .24);
  border-radius: 18px;
  color: var(--text);
  background: rgba(223, 247, 243, .70);
  line-height: 1.5;
}

@media (max-width: 920px) {
  .home-grid,
  .config-layout,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    min-height: auto;
  }
}

@media (max-width: 680px) {
  .app {
    width: min(100% - 18px, 1180px);
    padding-bottom: 34px;
  }

  .topbar {
    align-items: flex-start;
  }

  .brand-title span,
  .top-actions .pill {
    display: none;
  }

  .top-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .top-link-btn {
    min-height: 36px;
    padding: 0 10px;
    font-size: .78rem;
  }

  .language-actions,
  .mini-stats,
  .sliders,
  .segmented,
  .segmented.two,
  .choice-grid,
  .result-actions,
  .table-actions {
    grid-template-columns: 1fr;
  }

  .tables-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .hero-actions {
    display: grid;
  }

  .quick-practice-dock {
    grid-template-columns: 1fr;
  }

  .card-header {
    flex-direction: column;
  }

  .game-top {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .rank-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .rank-item .grade {
    grid-column: 1 / -1;
    width: 100%;
    height: 44px;
  }

  .modal-overlay {
    padding: 9px;
    align-items: start;
  }

  .modal-card {
    max-height: calc(100vh - 18px);
    border-radius: 24px;
  }

  .modal-head,
  .guide-actions {
    display: grid;
  }

  .modal-close {
    width: 100%;
  }

  .guide-grid,
  .guide-wide {
    grid-template-columns: 1fr;
  }
}

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