:root {
  color-scheme: light;
  --ink: #081a35;
  --muted: #52647d;
  --line: #b9c9d8;
  --blue: #078bd8;
  --blue-dark: #056aa6;
  --sky: #dff5ff;
  --mint: #e6faef;
  --green: #168a4e;
  --yellow: #ffe58a;
  --orange: #f47c20;
  --coral: #ff6f7d;
  --lavender: #eee7ff;
  --white: #ffffff;
  --shadow: 0 8px 22px rgba(8, 26, 53, .12);
}

* {
  box-sizing: border-box;
}

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

body {
  overflow-x: hidden;
  background:
    linear-gradient(110deg, rgba(148, 227, 208, .48), rgba(145, 216, 255, .46) 45%, rgba(255, 218, 231, .46)),
    #f7fbff;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

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

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 4px solid #ffbd17;
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(1180px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 0 40px rgba(8, 26, 53, .14);
}

.app-bar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 64px;
  padding: 8px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  border-bottom: 2px solid #a7d9ef;
  background: rgba(244, 251, 255, .97);
  box-shadow: 0 3px 12px rgba(8, 26, 53, .08);
}

.icon-button,
.brand-button,
.shortcut-button,
.plain-button,
.primary-button,
.danger-button,
.answer-button,
.action-tile,
.level-button,
.profile-chip,
.tab-button,
.icon-choice {
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 850;
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
}

.icon-button:active,
.brand-button:active,
.shortcut-button:active,
.plain-button:active,
.primary-button:active,
.danger-button:active,
.answer-button:active,
.action-tile:active,
.level-button:active,
.profile-chip:active,
.tab-button:active,
.icon-choice:active {
  transform: translateY(2px);
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border-color: #a8cadb;
  background: #fff;
  box-shadow: 0 3px 0 #a8cadb;
  font-size: 22px;
  line-height: 1;
}

#back-button {
  grid-column: 1;
}

.brand-button,
.brand-button:visited {
  grid-column: 2;
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  justify-self: start;
  padding: 4px 8px;
  background: transparent;
  color: #081a35;
  font-size: 20px;
  text-decoration: none;
  text-align: left;
}

.brand-button img {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
}

.brand-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-actions {
  display: flex;
  grid-column: 3;
  align-items: center;
  gap: 8px;
}

.language-control {
  display: block;
}

.language-control select {
  width: 62px;
  height: 44px;
  padding: 0 8px;
  border: 2px solid #a8cadb;
  border-radius: 8px;
  background: #fff;
  color: #082746;
  box-shadow: 0 3px 0 #a8cadb;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 850;
}

.language-control select:focus-visible {
  outline: 4px solid #ffbf00;
  outline-offset: 2px;
}

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

.shortcut-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 14px;
  border-color: #83bed9;
  background: #e5f6ff;
  color: #082746;
  box-shadow: 0 3px 0 #83bed9;
  font-size: 14px;
  white-space: nowrap;
}

.shortcut-label-short {
  display: none;
}

#screen {
  min-height: calc(100dvh - 94px);
  padding: 18px clamp(14px, 3vw, 34px) 38px;
}

.screen-stack {
  display: grid;
  gap: 18px;
  width: min(1040px, 100%);
  margin: 0 auto;
}

.screen-heading {
  margin: 0;
  font-size: 30px;
  line-height: 1.12;
}

.screen-lead {
  max-width: 760px;
  margin: -8px 0 0;
  color: var(--muted);
  font-size: 17px;
  font-weight: 650;
  line-height: 1.45;
}

.profile-row {
  display: flex;
  min-width: 0;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 6px;
  scrollbar-width: thin;
}

.profile-chip {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 12px;
  border-color: #b8c8d7;
  background: #fff;
  box-shadow: 0 3px 0 #b8c8d7;
}

.profile-chip.active {
  border-color: var(--blue);
  background: var(--sky);
  box-shadow: 0 3px 0 var(--blue);
}

.profile-avatar {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: var(--yellow);
  font-size: 17px;
}

.profile-points {
  color: var(--blue-dark);
  font-size: 14px;
}

.hero-stage {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 2100 / 652;
  border: 2px solid #54b9e4;
  border-radius: 8px;
  background: #dff7ff;
  box-shadow: var(--shadow);
}

.hero-stage img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

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

.action-tile {
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr) 34px;
  min-height: 112px;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-color: rgba(8, 26, 53, .2);
  box-shadow: 0 6px 0 rgba(8, 26, 53, .17), var(--shadow);
  text-align: left;
}

.action-tile.training {
  background: #dff3ff;
}

.action-tile.prizes {
  background: #fff1b9;
}

.action-tile img,
.menu-tile img {
  width: 58px;
  height: 58px;
  object-fit: contain;
}

.action-copy {
  min-width: 0;
}

.action-copy strong {
  display: block;
  margin-bottom: 5px;
  font-size: 24px;
  line-height: 1.1;
}

.action-copy small {
  display: block;
  color: #334965;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}

.action-arrow {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .8);
  font-size: 22px;
}

.utility-menu {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.menu-tile {
  display: flex;
  min-height: 78px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px;
  border: 2px solid #b9c9d8;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 4px 0 #b9c9d8;
  color: var(--ink);
  cursor: pointer;
  font-weight: 850;
  text-decoration: none;
}

.menu-tile img {
  width: 42px;
  height: 42px;
}

.level-intro {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-left: 6px solid var(--blue);
  background: var(--sky);
}

.level-intro.prizes {
  border-left-color: var(--orange);
  background: #fff4cb;
}

.level-intro img {
  width: 54px;
  height: 54px;
  object-fit: contain;
}

.level-intro strong {
  display: block;
  font-size: 19px;
}

.level-intro span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-weight: 650;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.level-button {
  position: relative;
  display: grid;
  min-height: 142px;
  align-content: center;
  gap: 8px;
  padding: 16px;
  border-color: rgba(8, 26, 53, .2);
  background: #fff;
  box-shadow: 0 5px 0 rgba(8, 26, 53, .16), var(--shadow);
  text-align: left;
}

.level-button:nth-child(1) { background: #e6f8ff; }
.level-button:nth-child(2) { background: #e6faef; }
.level-button:nth-child(3) { background: #fff3bd; }
.level-button:nth-child(4) { background: #ffe7df; }
.level-button:nth-child(5) { background: #eee7ff; }
.level-button:nth-child(6) { background: #e4f4ff; }

.level-button.locked {
  filter: grayscale(.55);
  opacity: .62;
}

.level-rank {
  color: var(--blue-dark);
  font-size: 13px;
  text-transform: uppercase;
}

.level-name {
  font-size: 23px;
  line-height: 1.05;
}

.level-rule {
  color: #3f536d;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}

.level-points {
  color: #9a4300;
  font-size: 14px;
}

.game-screen {
  display: grid;
  grid-template-rows: auto auto auto auto;
  gap: 12px;
  width: min(980px, 100%);
  min-height: calc(100dvh - 124px);
  margin: 0 auto;
}

.game-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(230px, 320px);
  gap: 12px;
}

.question-panel,
.streak-panel {
  min-width: 0;
  border: 2px solid #1a7fba;
  border-radius: 8px;
}

.question-panel {
  padding: 14px 18px;
  background: #eef8ff;
}

.level-label {
  color: #4d617b;
  font-size: 15px;
  font-weight: 850;
}

.question {
  margin: 5px 0 4px;
  font-size: 48px;
  font-weight: 950;
  line-height: 1.05;
}

.tip {
  margin: 0;
  color: #304962;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.35;
}

.streak-panel {
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 12px 16px;
  background: var(--mint);
}

.mode-label {
  color: var(--green);
  font-size: 18px;
  font-weight: 900;
}

.mode-label.training {
  color: var(--blue-dark);
}

.streak-value {
  font-size: 20px;
  font-weight: 900;
}

.bonus-next {
  color: #4e6178;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}

.game-stage {
  overflow: hidden;
  width: 100%;
  aspect-ratio: 2100 / 652;
  border: 2px solid #57bce5;
  border-radius: 8px;
  background: #dcf5ff;
}

.game-stage img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

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

.answer-button {
  min-height: 66px;
  padding: 10px 14px;
  border-color: #9c7b00;
  background: var(--yellow);
  box-shadow: 0 4px 0 #9c7b00;
  font-size: 27px;
}

.typing-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 10px;
}

.typing-area input,
.form-field input,
.form-field select,
.pin-form input {
  width: 100%;
  min-height: 50px;
  padding: 10px 12px;
  border: 2px solid #9db3c5;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.typing-area input {
  min-height: 66px;
  font-size: 28px;
  font-weight: 900;
  text-align: center;
}

.primary-button,
.plain-button,
.danger-button {
  min-height: 48px;
  padding: 10px 16px;
}

.primary-button {
  border-color: #08699d;
  background: #19a5e7;
  box-shadow: 0 4px 0 #08699d;
  color: #fff;
}

.plain-button {
  border-color: #9fb3c5;
  background: #fff;
  box-shadow: 0 3px 0 #9fb3c5;
}

.danger-button {
  border-color: #a92b37;
  background: #ff7d88;
  box-shadow: 0 3px 0 #a92b37;
  color: #421015;
}

.game-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  min-height: 42px;
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  background: #e7fbf2;
  font-size: 14px;
  font-weight: 850;
}

.game-stats span:nth-child(2) { text-align: center; }
.game-stats span:nth-child(3) { text-align: right; }

.store-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.prize-card {
  display: grid;
  min-height: 210px;
  align-content: start;
  gap: 10px;
  padding: 16px;
  border: 2px solid #d6b750;
  border-radius: 8px;
  background: #fff8d8;
  box-shadow: 0 5px 0 #d6b750, var(--shadow);
}

.prize-icon {
  font-size: 46px;
}

.prize-title {
  margin: 0;
  font-size: 21px;
  line-height: 1.15;
}

.prize-cost {
  color: #854100;
  font-weight: 900;
}

.prize-card button {
  align-self: end;
  margin-top: auto;
}

.notice-band {
  padding: 12px 14px;
  border-left: 5px solid var(--orange);
  background: #fff3cf;
  color: #573300;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}

.parent-screen {
  width: min(1100px, 100%);
  margin: 0 auto;
}

.parent-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 7px;
}

.tab-button {
  flex: 0 0 auto;
  min-height: 46px;
  padding: 9px 13px;
  border-color: #a7b9ca;
  background: #fff;
}

.tab-button.active {
  border-color: var(--blue);
  background: var(--sky);
  color: #005d91;
}

.parent-content {
  display: grid;
  gap: 16px;
  padding-top: 14px;
}

.settings-section {
  display: grid;
  gap: 12px;
  padding: 16px 0;
  border-top: 2px solid #d9e3eb;
}

.settings-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.settings-title {
  margin: 0;
  font-size: 22px;
}

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

.edit-row,
.request-row,
.history-row {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 2px solid #c7d5e1;
  border-radius: 8px;
  background: #f8fbfd;
}

.edit-row.selected {
  border-color: var(--blue);
  background: var(--sky);
}

.row-heading {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.row-heading strong {
  overflow-wrap: anywhere;
}

.row-actions,
.form-actions,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

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

.form-field {
  display: grid;
  align-content: start;
  gap: 6px;
  color: #334861;
  font-size: 14px;
  font-weight: 800;
}

.form-field.full {
  grid-column: 1 / -1;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 10px 12px;
  border: 2px solid #c3d1dd;
  border-radius: 8px;
  background: #fff;
  font-weight: 750;
}

.switch-row input {
  width: 22px;
  height: 22px;
  accent-color: var(--blue);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 2px solid #b7c8d6;
  border-radius: 8px;
  background: #eaf1f6;
}

.segmented button {
  min-height: 48px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-weight: 850;
}

.segmented button.active {
  background: #fff;
  box-shadow: 0 2px 7px rgba(8, 26, 53, .16);
  color: var(--blue-dark);
}

.icon-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.icon-choice {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-color: #becbd7;
  background: #fff;
  font-size: 25px;
}

.icon-choice.active {
  border-color: var(--blue);
  background: var(--sky);
}

.empty-state {
  padding: 24px 16px;
  border: 2px dashed #adc0d0;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

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

.help-item {
  padding: 15px 16px;
  border-left: 5px solid var(--blue);
  background: #eef8ff;
}

.help-item:nth-child(2n) {
  border-left-color: var(--green);
  background: #ecfaf2;
}

.help-item h2 {
  margin: 0 0 6px;
  font-size: 19px;
}

.help-item p {
  margin: 0;
  color: #3f536c;
  font-weight: 650;
  line-height: 1.45;
}

.text-link {
  color: #006fae;
  font-weight: 850;
}

.app-credit {
  display: flex;
  min-height: 30px;
  align-items: center;
  justify-content: flex-end;
  padding: 4px max(12px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom));
  font-size: 12px;
}

.app-credit a {
  color: #53647a;
  font-weight: 700;
  text-decoration: none;
}

.modal-layer {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  overflow-y: auto;
  place-items: center;
  padding: 18px;
  background: rgba(6, 19, 38, .64);
}

.modal-card {
  display: grid;
  width: min(510px, 100%);
  gap: 13px;
  padding: 22px;
  border: 3px solid #0c79b8;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 50px rgba(0, 0, 0, .3);
  text-align: center;
}

.modal-card.success {
  border-color: #159454;
  background: #effbf4;
}

.modal-card.error {
  border-color: #d23948;
  background: #fff1f2;
}

.modal-card.reward {
  border-color: #d89400;
  background: #fff7d7;
}

.modal-image {
  width: 104px;
  height: 104px;
  margin: 0 auto;
  object-fit: contain;
}

.modal-card h2 {
  margin: 0;
  font-size: 27px;
  line-height: 1.15;
}

.modal-body {
  color: #344960;
  font-weight: 650;
  line-height: 1.5;
}

.modal-body p {
  margin: 0 0 10px;
}

.modal-body p:last-child {
  margin-bottom: 0;
}

.modal-body input {
  width: 100%;
  min-height: 52px;
  padding: 10px 12px;
  border: 2px solid #9db3c5;
  border-radius: 8px;
  font-size: 18px;
}

.modal-actions {
  justify-content: center;
}

.toast {
  position: fixed;
  z-index: 130;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100% - 36px));
  padding: 13px 16px;
  border: 2px solid #0b6f9f;
  border-radius: 8px;
  background: #062a41;
  box-shadow: var(--shadow);
  color: #fff;
  font-weight: 800;
}

@media (hover: hover) {
  .icon-button:hover,
  .shortcut-button:hover,
  .plain-button:hover,
  .primary-button:hover,
  .danger-button:hover,
  .answer-button:hover,
  .action-tile:hover,
  .level-button:hover,
  .profile-chip:hover,
  .tab-button:hover,
  .icon-choice:hover,
  .menu-tile:hover {
    filter: brightness(1.035);
    transform: translateY(-2px);
  }
}

@media (max-width: 760px) {
  #screen {
    padding: 14px 12px 34px;
  }

  .screen-heading {
    font-size: 26px;
  }

  .home-actions,
  .store-grid,
  .level-grid,
  .list-grid,
  .help-list {
    grid-template-columns: 1fr;
  }

  .action-tile {
    min-height: 96px;
    grid-template-columns: 54px minmax(0, 1fr) 30px;
    gap: 11px;
    padding: 12px;
  }

  .action-tile img {
    width: 50px;
    height: 50px;
  }

  .action-copy strong {
    font-size: 21px;
  }

  .utility-menu {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .menu-tile {
    display: grid;
    justify-items: center;
    gap: 4px;
    min-width: 0;
    font-size: 13px;
    text-align: center;
  }

  .level-button {
    min-height: 112px;
  }

  .game-screen {
    min-height: calc(100dvh - 112px);
    gap: 9px;
  }

  .game-top {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .question-panel {
    padding: 10px 13px;
  }

  .question {
    font-size: 38px;
  }

  .streak-panel {
    grid-template-columns: 1fr auto;
    gap: 3px 10px;
    padding: 9px 12px;
  }

  .streak-panel .bonus-next {
    grid-column: 1 / -1;
  }

  .mode-label,
  .streak-value {
    font-size: 16px;
  }

  .answer-button {
    min-height: 58px;
    font-size: 24px;
  }

  .typing-area {
    grid-template-columns: 1fr 120px;
  }

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

  .form-field.full {
    grid-column: auto;
  }
}

@media (max-width: 440px) {
  .app-bar {
    grid-template-columns: 42px minmax(0, 1fr) auto;
    min-height: 58px;
    padding: 6px 8px;
  }

  .icon-button {
    width: 38px;
    height: 38px;
    font-size: 19px;
  }

  .shortcut-button {
    min-height: 38px;
    padding: 0 10px;
    font-size: 13px;
  }

  .language-control select {
    width: 52px;
    height: 38px;
    padding: 0 5px;
    font-size: 12px;
  }

  .shortcut-label-full {
    display: none;
  }

  .shortcut-label-short {
    display: inline;
  }

  .brand-button {
    gap: 7px;
    padding: 3px 5px;
    font-size: 16px;
  }

  .brand-button img {
    width: 36px;
    height: 36px;
  }

  .utility-menu {
    gap: 6px;
  }

  .menu-tile {
    min-height: 72px;
    padding: 7px 4px;
  }

  .menu-tile img {
    width: 34px;
    height: 34px;
  }

  .answer-grid {
    gap: 7px;
  }

  .answer-button {
    padding: 8px;
  }

  .game-stats {
    padding: 7px 8px;
    font-size: 12px;
  }

  .modal-card {
    padding: 17px 14px;
  }
}

@media (max-height: 700px) and (min-width: 600px) {
  #screen {
    padding-top: 10px;
    padding-bottom: 24px;
  }

  .game-screen {
    gap: 7px;
  }

  .game-stage {
    max-height: 128px;
  }

  .question-panel {
    padding: 9px 14px;
  }

  .question {
    font-size: 38px;
  }

  .answer-button {
    min-height: 52px;
  }
}

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