@import url("https://fonts.googleapis.com/css2?family=Baloo+2:wght@600;700&family=Nunito:wght@400;700&display=swap");

:root {
  --bg-sky: #dff1ff;
  --bg-sun: #fff4c7;
  --bg-peach: #ffe5d1;
  --ink: #1f2330;
  --muted: #5c6375;
  --primary: #2e7be8;
  --primary-dark: #1b5db8;
  --secondary: #ff914d;
  --card: #ffffff;
  --border: #f4c36a;
  --shadow: 0 16px 30px rgba(31, 35, 48, 0.12);
  --keyboard-offset: 0px;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

body {
  width: 100%;
  max-width: 100%;
}

body {
  margin: 0;
  font-family: "Nunito", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background-color: var(--bg-sky);
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20width%3D%27520%27%20height%3D%27520%27%20viewBox%3D%270%200%20520%20520%27%3E%0A%20%20%3Cg%20opacity%3D%270.18%27%3E%0A%20%20%20%20%3Ctext%20x%3D%2740%27%20y%3D%2790%27%20font-size%3D%2740%27%20transform%3D%27rotate%28-12%2040%2090%29%27%3E%F0%9F%A6%B8%E2%80%8D%E2%99%82%EF%B8%8F%3C/text%3E%0A%20%20%20%20%3Ctext%20x%3D%27360%27%20y%3D%2780%27%20font-size%3D%2736%27%20transform%3D%27rotate%2818%20360%2080%29%27%3E%E2%9E%97%3C/text%3E%0A%20%20%20%20%3Ctext%20x%3D%27380%27%20y%3D%27260%27%20font-size%3D%2740%27%20transform%3D%27rotate%28-18%20380%20260%29%27%3E%F0%9F%A6%B8%E2%80%8D%E2%99%80%EF%B8%8F%3C/text%3E%0A%20%20%20%20%3Ctext%20x%3D%2790%27%20y%3D%27270%27%20font-size%3D%2736%27%20transform%3D%27rotate%2810%2090%20270%29%27%3E%E2%9C%96%EF%B8%8F%3C/text%3E%0A%20%20%20%20%3Ctext%20x%3D%27230%27%20y%3D%27380%27%20font-size%3D%2736%27%20transform%3D%27rotate%28-8%20230%20380%29%27%3E%E2%9E%95%3C/text%3E%0A%20%20%20%20%3Ctext%20x%3D%2760%27%20y%3D%27450%27%20font-size%3D%2740%27%20transform%3D%27rotate%2816%2060%20450%29%27%3E%F0%9F%A7%AE%3C/text%3E%0A%20%20%20%20%3Ctext%20x%3D%27360%27%20y%3D%27470%27%20font-size%3D%2736%27%20transform%3D%27rotate%286%20360%20470%29%27%3E%F0%9F%94%A2%3C/text%3E%0A%20%20%3C/g%3E%0A%3C/svg%3E"), radial-gradient(circle at top left, var(--bg-sun), var(--bg-sky) 45%, var(--bg-peach) 85%);
  background-size: 520px 520px, cover;
  background-repeat: repeat, no-repeat;
  background-position: 0 0, center;
  min-height: 100dvh;
  overscroll-behavior-x: none;
  -webkit-overflow-scrolling: touch;
}

img,
svg,
video,
canvas {
  max-width: 100%;
  height: auto;
}

.page {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 32px 20px calc(140px + env(safe-area-inset-bottom));
  position: relative;
  animation: pageIn 0.6s ease-out;
  overflow-x: clip;
}

.page::before,
.page::after {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  opacity: 0.35;
  filter: blur(0.5px);
  z-index: -1;
}

.page::before {
  top: -40px;
  right: -60px;
  background: radial-gradient(circle, #ffcf6b, transparent 65%);
}

.page::after {
  bottom: -60px;
  left: -40px;
  background: radial-gradient(circle, #7bdff6, transparent 65%);
}

.hero {
  text-align: center;
  margin-bottom: 30px;
}

.tag {
  display: inline-block;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: #fff;
  padding: 6px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.hero h1 {
  font-family: "Baloo 2", "Comic Sans MS", cursive;
  font-size: clamp(2rem, 4vw, 3.4rem);
  margin: 0 0 8px;
}

.subtitle {
  margin: 0 auto;
  max-width: 520px;
  color: var(--muted);
  font-size: 1.05rem;
}

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

.layout > * {
  min-width: 0;
}

.card {
  background: var(--card);
  border-radius: 24px;
  padding: 22px 22px 26px;
  box-shadow: var(--shadow);
  border: 2px solid #fff4d9;
}

.card.list {
  justify-self: center;
  width: 100%;
}

.card.settings {
  justify-self: center;
  width: 100%;
  max-width: 600px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.list-head {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "title button"
    "subtitle subtitle";
  column-gap: 16px;
  row-gap: 8px;
  align-items: start;
}

.list-head > div {
  display: contents;
}

.list-head h2 {
  grid-area: title;
}

.list-head .list-summary {
  grid-area: subtitle;
}

.list-head .ghost {
  grid-area: button;
  justify-self: end;
  align-self: start;
  margin-top: 2px;
}
.card-head > div {
  flex: 1;
}

.card-head h2 {
  margin: 0 0 4px;
  font-family: "Baloo 2", "Comic Sans MS", cursive;
  font-size: 1.6rem;
}

.card-head h2 .title-break {
  display: inline;
}

.note {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.list-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.summary-lead {
  flex-basis: 100%;
  display: block;
  font-weight: 700;
  color: var(--ink);
}

.summary-accent {
  color: #2f6f8f;
  font-weight: 800;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  text-decoration-color: rgba(47, 111, 143, 0.45);
}

.summary-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.summary-chips::-webkit-scrollbar {
  height: 0;
}

.summary-chip {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f4fbff;
  border: 1px solid #9fd6f4;
  font-size: 0.85rem;
  font-weight: 700;
  color: #2f6f8f;
  white-space: nowrap;
}

.field {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

label,
legend {
  font-weight: 700;
}

input[type="number"] {
  padding: 10px 12px;
  border-radius: 14px;
  border: 2px solid #dce3f1;
  font-size: 1rem;
  max-width: 140px;
}

.helper {
  color: var(--muted);
  font-size: 0.85rem;
}

.numbers-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(44px, 1fr));
  gap: 10px;
}

.number-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 4px;
  border-radius: 14px;
  border: 2px dashed #ffd58c;
  background: #fff7e1;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.number-chip input {
  accent-color: var(--primary);
}

.number-chip:hover {
  transform: translateY(-2px);
  border-color: var(--secondary);
}

.mode-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: #eef6ff;
  border: 2px solid #cce3ff;
  font-weight: 700;
}

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

button {
  border: none;
  border-radius: 16px;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  max-width: 100%;
  white-space: normal;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.ghost {
  background: #fff;
  color: var(--primary-dark);
  border: 2px dashed #cce3ff;
  box-shadow: none;
  padding: 10px 16px;
}

.ghost:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(46, 123, 232, 0.18);
}

.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 10px 20px rgba(46, 123, 232, 0.25);
}

.primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(46, 123, 232, 0.35);
}

.secondary {
  background: #ffe1c2;
  color: #7a3f00;
  box-shadow: 0 10px 20px rgba(255, 145, 77, 0.25);
}

.status {
  margin-top: 18px;
  background: #f6f9ff;
  border-radius: 16px;
  padding: 14px 16px;
  border: 2px solid #e0ecff;
}

.status-item {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1.1rem;
}

.status-label {
  color: var(--muted);
}

.status-message {
  margin: 8px 0 0;
  color: var(--primary-dark);
  font-weight: 700;
}

.table {
  display: grid;
  gap: 12px;
  margin: 18px auto 0;
}

.row {
  display: grid;
  grid-template-columns: minmax(80px, 0.6fr) minmax(140px, 1fr) minmax(80px, 0.5fr);
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-radius: 18px;
  border: 2px dashed #e9c27b;
  background: #fff9e8;
  animation: rowIn 0.4s ease var(--delay, 0ms) both;
  text-align: center;
}

.row.head {
  background: transparent;
  border: none;
  padding: 0 4px;
  font-weight: 700;
  text-align: center;
}

.cell {
  font-size: 1.05rem;
  font-weight: 700;
}

.row .cell:first-child {
  font-size: 1.2rem;
}

.answer-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid #dce3f1;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
}

.answer-col {
  color: #2c7a2c;
}

.row.correct .answer-input {
  border-color: #2c7a2c;
  background: #effbf0;
}

.row.wrong .answer-input {
  border-color: #d64545;
  background: #fff0f0;
}

.row.wrong .answer-col {
  color: #d64545;
}

.hide-answers .answer-col {
  display: none;
}

.hide-answers .row {
  grid-template-columns: minmax(80px, 0.6fr) 1fr;
}

body.settings-hidden .settings {
  display: none;
}

body.settings-hidden .layout {
  grid-template-columns: 1fr;
}

body.settings-hidden .card.list,
body.settings-hidden .table,
body.settings-hidden .result-banner {
  max-width: 600px;
}

body.settings-hidden .bar-row,
body.settings-hidden .bar-message {
  max-width: 600px;
}

body:not(.settings-hidden) .layout {
  grid-template-columns: 1fr;
}

body:not(.settings-hidden) .card.list,
body:not(.settings-hidden) .fixed-bar,
body:not(.settings-hidden) .floating-nav {
  display: none;
}

.result-banner {
  margin: 18px auto 0;
  padding: 18px 20px;
  border-radius: 20px;
  background: linear-gradient(135deg, #fff3b0, #ffe4d6);
  border: 2px solid #ffd28a;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 12px 24px rgba(255, 145, 77, 0.2);
}

.result-banner.excellent {
  background: linear-gradient(135deg, #d6ffe0, #fff6c7);
  border-color: #78d88b;
  box-shadow: 0 14px 28px rgba(90, 200, 120, 0.25);
}

.result-banner.good {
  background: linear-gradient(135deg, #dff1ff, #ffe8d1);
  border-color: #7fc8ff;
  box-shadow: 0 14px 28px rgba(80, 150, 220, 0.2);
}

.result-banner.ok {
  background: linear-gradient(135deg, #fff7e0, #ffe1ef);
  border-color: #ffb2d1;
  box-shadow: 0 14px 28px rgba(255, 170, 200, 0.2);
}

.result-banner.low {
  background: linear-gradient(135deg, #fff0f0, #ffe4d1);
  border-color: #f08a8a;
  box-shadow: 0 14px 28px rgba(220, 120, 120, 0.22);
}

.result-banner::before,
.result-banner::after {
  content: "";
  position: absolute;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 210, 120, 0.6), transparent 70%);
  opacity: 0.8;
}

.result-banner::before {
  top: -60px;
  left: -50px;
}

.result-banner::after {
  bottom: -70px;
  right: -40px;
}

.result-title {
  font-family: "Baloo 2", "Comic Sans MS", cursive;
  font-size: 1.8rem;
  letter-spacing: 0.04em;
}

.result-emoji {
  font-size: 2.6rem;
  line-height: 1;
  margin-bottom: 6px;
}

.result-text {
  margin: 6px 0 0;
  font-weight: 700;
  color: var(--primary-dark);
}

.result-banner.low .result-text {
  color: #a63434;
}

.result-score {
  margin: 8px 0 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: #2c7a2c;
}

.fixed-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--keyboard-offset, 0px);
  z-index: 10;
  background: #fffef9;
  border-top: 2px solid #ffe2a8;
  box-shadow: 0 -12px 24px rgba(31, 35, 48, 0.12);
  padding: 12px 20px calc(16px + env(safe-area-inset-bottom));
}

.training-mode .bar-timer {
  display: none;
}

.training-mode .bar-row {
  justify-content: center;
}

.bar-row {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.bar-timer {
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
  font-weight: 700;
}

.bar-label {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
}

.bar-value {
  font-size: 1.5rem;
  font-family: "Baloo 2", "Comic Sans MS", cursive;
}

.bar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bar-message {
  max-width: 1100px;
  margin: 8px auto 0;
  font-weight: 700;
  color: var(--primary-dark);
}

.floating-nav {
  position: fixed;
  right: 18px;
  bottom: calc(92px + var(--keyboard-offset, 0px));
  display: none;
  flex-direction: column;
  gap: 12px;
  z-index: 20;
}

.nav-dot {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid #1b5db8;
  background: #1b5db8;
  color: #ffffff;
  font-size: 1.2rem;
  font-weight: 700;
  box-shadow: 0 12px 22px rgba(27, 93, 184, 0.35);
  display: grid;
  place-items: center;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: block;
  fill: currentColor;
  overflow: visible;
}

.nav-icon path {
  transform: scale(4);
  transform-origin: center;
  transform-box: fill-box;
}

.nav-dot--secondary {
  background: #e9f2ff;
  border-color: #9fc0f2;
  color: #1b5db8;
  box-shadow: 0 8px 16px rgba(27, 93, 184, 0.18);
}

.nav-dot:active {
  transform: translateY(1px);
}

.nav-dot:focus-visible {
  outline: 3px solid #ffb04d;
  outline-offset: 3px;
}

@keyframes pageIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes rowIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 520px) {
  .numbers-grid {
    grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
  }

  input[type="number"] {
    max-width: none;
    width: 100%;
  }

  .list-head {
    column-gap: 10px;
  }

  .list-head h2 {
    font-size: 1.35rem;
    line-height: 1.1;
  }

  .list-head h2 .title-break {
    display: block;
  }

  .list-head .ghost {
    padding: 6px 10px;
    font-size: 0.9rem;
    line-height: 1.15;
    border-radius: 12px;
    border-width: 1px;
    text-align: center;
    width: 120px;
    white-space: normal;
  }
}

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

  .settings {
    order: 1;
  }

  .list {
    order: 2;
  }

  .row,
  .hide-answers .row {
    grid-template-columns: 1fr;
  }

  .row.head {
    display: none;
  }

  .cell {
    font-size: 1rem;
  }

  .card-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .fixed-bar {
    padding: 10px 12px 14px;
  }

  .bar-row {
    gap: 8px;
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
  }

  .bar-timer {
    justify-content: flex-start;
  }

  .bar-actions {
    justify-content: flex-end;
    width: auto;
    flex-wrap: nowrap;
    gap: 6px;
  }

  .bar-value {
    font-size: 1.2rem;
  }

  .bar-actions button {
    padding: 10px 14px;
    font-size: 0.92rem;
  }

  body.settings-hidden.answer-focus .floating-nav {
    display: flex;
  }

  .floating-nav {
    right: 14px;
    bottom: calc(88px + var(--keyboard-offset, 0px));
  }
}
