@import url("https://fonts.googleapis.com/css2?family=Gaegu:wght@400;700&family=Klee+One:wght@400;600&family=Song+Myung&family=Yuji+Mai&display=swap");

@font-face {
  font-family: "LXGW WenKai Lite";
  src: url("../fonts/LXGWWenKaiLite-Regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "LXGW WenKai Lite";
  src: url("../fonts/LXGWWenKaiLite-Medium.woff2") format("woff2");
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
}

:root {
  --bg: #fed65a;
  --bg-soft: #ffe6a7;
  --board: #ffe6a7;
  --ink: #2b261c;
  --line: #000;
  --hi: #f3c39a;
  --hi-soft: #ffd48a;
  --bubble: #ffffff;
  --good: #3c8a4a;
  --good-bg: #b7e4c0;
  --ok-bg: #7eb8e6;
  --bad: #c45c5c;
  --shadow: rgba(80, 60, 20, 0.08);
  --cell: clamp(28px, 7.2vmin, 64px);
  --ui: "Gaegu", "Klee One", sans-serif;
  --kanji: "Yuji Mai", "Klee One", "Yu Mincho", serif;
  --hangul-piece: "Gungsuh", "GungSeo", "궁서", "Song Myung", serif;
  --coord: #c43c1a;
  --piece: #1d5aa6;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
}

body {
  overflow: hidden;
}

button,
select {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.hidden {
  display: none !important;
}

.app-shell {
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-areas:
    "top"
    "main";
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.topbar {
  grid-area: top;
}

.ad-banner {
  display: block;
  width: 100%;
  line-height: 0;
  background: transparent;
  text-decoration: none;
  flex-shrink: 0;
}

.ad-banner-mobile,
.bottom-slot,
.lesson-prompt,
.lesson-dock {
  display: none;
}

.hamburger {
  display: none;
}

.panel-dialog-bar,
.top-actions.panel-nav {
  display: none;
}

.layout {
  grid-area: main;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 0;
  gap: 12px;
}

.brand {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0.04em;
}

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

.ghost-btn,
.primary-btn,
.soft-btn,
.card,
.chapter-card {
  border: 0;
  background: #fff;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 18px;
  box-shadow: none;
}

.ghost-btn.active,
.ghost-btn:hover,
.primary-btn:hover,
.soft-btn:hover {
  background: #fff;
}

:is(#btn-bgm, [data-bgm])[aria-pressed="false"] {
  background: #efe2b8;
  color: #7a6a48;
}

.nav-prev {
  background: #d8c9a4;
  color: #4a3b28;
}

.nav-prev:hover {
  background: #cbb890;
  color: #4a3b28;
}

.nav-next {
  background: #2f7d4a;
  color: #fff;
}

.nav-next:hover {
  background: #25663c;
  color: #fff;
}

.nav-next-lesson {
  background: #1d5aa6;
  color: #fff;
}

.nav-next-lesson:hover {
  background: #164781;
  color: #fff;
}

.layout {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) auto minmax(280px, 1.15fr);
  align-items: stretch;
  gap: 12px 8px;
  padding: 8px 16px 0;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.panel-wrap {
  min-width: 0;
  min-height: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: #e8c56a transparent;
}

.panel-body {
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.ad-banner-panel {
  margin-top: auto;
  overflow: hidden;
}

.board-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.character-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  width: 100%;
  min-height: 0;
  padding-bottom: 0;
  overflow: hidden;
}

.character-stage > #char-gif {
  width: min(100%, 46vw, 720px);
  max-height: calc(100dvh - 72px);
  height: auto;
  object-fit: contain;
  object-position: center bottom;
  image-rendering: auto;
}

.screen-play .character-stage:has(#play-clock-pc:not(.hidden)) {
  justify-content: flex-end;
  padding-bottom: 10px;
}

.screen-play .character-stage:has(#play-clock-pc:not(.hidden)) > #char-gif {
  max-height: calc(100dvh - 220px);
}

.play-clock {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

#play-clock-pc {
  margin-top: 8px;
}

.clock-cell {
  position: relative;
  width: min(120px, 13vw);
}

.clock-cell img {
  display: block;
  width: 100%;
  height: auto;
}

.clock-num {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 12%;
  height: 58%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  color: #fff;
  font-weight: 700;
  font-size: clamp(28px, 4vw, 44px);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  pointer-events: none;
}

.clock-unit {
  position: absolute;
  left: 18%;
  right: 8%;
  bottom: 4.5%;
  height: 17%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #2c2825;
  font-weight: 700;
  font-size: clamp(13px, 1.6vw, 18px);
  line-height: 1;
  pointer-events: none;
}

.play-clock.is-byo .clock-cell:last-child .clock-num {
  animation: clock-pulse 1s ease-in-out infinite;
}

.play-clock.is-flag .clock-num {
  opacity: 0.7;
}

@keyframes clock-pulse {
  50% {
    transform: scale(1.06);
  }
}

.clock-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  margin: 0 0 12px;
}

.clock-toggle input {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  accent-color: #2f7d4a;
}

.clock-toggle strong {
  display: block;
}

.clock-toggle em {
  display: block;
  font-style: normal;
  font-size: 15px;
  opacity: 0.75;
}

.hand-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
  min-height: 42px;
  width: min(100%, calc(var(--cell) * 9));
}

.hand-row.gote {
  margin-bottom: 6px;
}

.hand-row.sente {
  margin-top: 4px;
}

.hand-piece {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: transparent;
  border: 0;
  padding: 0;
  width: calc(var(--cell) * 0.72);
  height: calc(var(--cell) * 0.78);
  background-image: url("../images/char.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  font-size: calc(var(--cell) * 0.36);
  line-height: 1;
}

.hand-piece .glyph {
  font-family: var(--kanji);
}

.hand-piece.hangul .glyph {
  font-family: var(--hangul-piece);
  font-size: calc(var(--cell) * 0.42);
}

.hand-piece.gote {
  transform: rotate(180deg);
}

.hand-piece .count {
  font-size: 0.7em;
}

.hand-piece.selected {
  background: var(--hi);
  border-radius: 8px;
}

.board-shell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.coord-files,
.coord-ranks {
  font-family: var(--kanji);
  font-size: calc(var(--cell) * 0.28);
  color: var(--ink);
  line-height: 1;
}

.coord-files {
  display: grid;
  grid-template-columns: repeat(9, var(--cell));
  width: calc(var(--cell) * 9);
  margin: 0 0 4px 14px;
  text-align: center;
}

.board-mid {
  display: flex;
  align-items: flex-start;
}

.coord-ranks {
  display: grid;
  grid-template-rows: repeat(9, var(--cell));
  margin-top: 14px;
  padding-left: 6px;
  place-items: center;
}

.board-wrap {
  position: relative;
  background: var(--board);
  padding: 14px;
  border: 0;
}

.board {
  touch-action: manipulation;
  display: grid;
  grid-template-columns: repeat(9, var(--cell));
  grid-template-rows: repeat(9, var(--cell));
  border: 1px solid #000;
  background: var(--board);
}

.sq {
  border: 0;
  border-right: 1px solid #000;
  border-bottom: 1px solid #000;
  background: var(--board);
  display: grid;
  place-items: center;
  position: relative;
  user-select: none;
  padding: 0;
  margin: 0;
}

.sq:nth-child(9n) {
  border-right: 0;
}

.sq:nth-child(n + 73) {
  border-bottom: 0;
}

.sq.last,
.sq.hint {
  background: var(--hi);
}

.sq.selected {
  background: var(--hi-soft);
}

.sq.check {
  background: #f5b8b0;
}

.piece {
  font-family: var(--kanji);
  font-size: calc(var(--cell) * 0.42);
  line-height: 1;
  color: var(--ink);
  pointer-events: none;
  width: 86%;
  height: 90%;
  display: grid;
  place-items: center;
  background-image: url("../images/char.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.piece.hangul {
  font-family: var(--hangul-piece);
  font-size: calc(var(--cell) * 0.42);
  font-weight: 400;
}

.piece.gote {
  transform: rotate(180deg);
}

.move-line {
  margin: 8px 0 0;
  font-size: 22px;
  text-align: center;
  letter-spacing: 0.04em;
}

.lesson-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 12px;
}

.speech {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  margin: 0 0 28px;
}

.speech.bad {
  grid-template-columns: auto 1fr;
}

.bubble {
  position: relative;
  isolation: isolate;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 22px 34px 20px 26px;
  font-size: 20px;
  line-height: 1.45;
  min-height: 72px;
}

.bubble::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-style: solid;
  border-color: transparent;
  border-width: 28px 22px 26px 38px;
  border-image-source: url("../images/chat-box.png");
  border-image-slice: 32 22 28 40 fill;
  border-image-width: 28px 22px 26px 38px;
  border-image-repeat: stretch;
  pointer-events: none;
}

.speech.bad .bubble {
  padding: 22px 26px 20px 34px;
}

.speech.bad .bubble::before {
  transform: scaleX(-1);
}

.speech.ask .bubble {
  max-width: none;
}

.coord-mark {
  color: var(--coord);
  font-weight: 700;
  font-family: var(--kanji);
}

.piece-mark {
  color: var(--piece);
  font-weight: 700;
}

.mascot {
  width: 96px;
  height: auto;
  flex: 0 0 auto;
  object-fit: contain;
}

.mascot-yuki {
  width: 88px;
}

.verdict {
  text-align: center;
  font-size: 22px;
  margin: 0 0 20px;
}

.verdict.good {
  color: var(--good);
}

.verdict.bad {
  color: var(--bad);
}

.lesson-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.primary-btn,
.soft-btn {
  padding: 8px 16px;
}

@keyframes guide-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.22;
  }
}

.sq.correct,
.sq.hint.correct,
.sq.last.correct {
  background: var(--ok-bg);
}

.choice-ok,
.promo-pop button.choice-ok {
  background: #2f7d4a;
  color: #fff;
}

.choice-ok:hover,
.promo-pop button.choice-ok:hover {
  background: #25663c;
  color: #fff;
}

.sq.guide-blink .piece,
.sq.guide-blink:not(:has(.piece)),
.hand-piece.guide-blink,
button.guide-blink {
  animation: guide-blink 1.8s ease-in-out infinite;
}

.progress-note {
  font-size: 18px;
  margin: 0;
}

.chapter-list,
.home-grid {
  display: grid;
  gap: 10px;
}

.home-grid {
  grid-template-columns: 1fr;
  width: 100%;
}

.level-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 14px;
}

.level-card {
  display: grid;
  gap: 4px;
}

.level-card span {
  font-size: 15px;
  line-height: 1.4;
}

.level-card.is-picked,
.lang-switch.is-picked {
  box-shadow: inset 0 0 0 3px #3a7a4a;
}

.lang-switch-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.lang-switch {
  text-align: center;
  font-weight: 800;
}

.card,
.chapter-card {
  border-radius: 22px;
  padding: 14px 16px;
  text-align: left;
}

.chapter-card {
  width: 100%;
  display: grid;
  gap: 6px;
}

.chapter-card .meta {
  display: flex;
  justify-content: space-between;
  font-size: 16px;
}

.bar {
  height: 8px;
  background: #f0e3a8;
  border-radius: 999px;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  background: #f2a36a;
}

.cat-title {
  margin: 18px 0 8px;
  font-size: 22px;
}

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(70, 50, 10, 0.18);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 16px;
}

.modal {
  width: min(440px, 100%);
  background: var(--bg-soft);
  border: 3px solid var(--ink);
  border-radius: 28px;
  padding: 22px;
}

.modal h2 {
  margin: 0 0 12px;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
  font-size: 20px;
}

.setting-row select {
  border: 0;
  border-radius: 999px;
  background: #fff;
  padding: 6px 10px;
  font-size: 18px;
}

.promo-pop {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border: 0;
  border-radius: 24px;
  padding: 14px 16px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 180px;
}

.ai-line {
  font-size: 16px;
  opacity: 0.8;
  text-align: center;
  margin: 4px 0 0;
}

.screen-home .character-stage,
.screen-chapters .character-stage {
  align-items: center;
}

.screen-home .panel-wrap {
  position: relative;
}

.screen-home .panel-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1 1 auto;
  padding-bottom: calc(100% * 700 / 1360);
}

.screen-home .ad-banner-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin-top: 0;
}

.screen-home .board-column,
.screen-chapters .board-column,
.screen-lesson .board-column,
.screen-play .board-column {
  align-self: center;
}

.screen-chapters .layout,
.screen-lesson .layout,
.screen-play .layout {
  align-items: stretch;
}

.screen-chapters .panel-wrap,
.screen-lesson .panel-wrap,
.screen-play .panel-wrap {
  align-self: stretch;
}

.screen-lesson .panel-body,
.screen-play .panel-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.screen-lesson .speech,
.screen-play .speech {
  margin: 0 0 16px;
}

/* Compact screens prioritize readable instructions and a fully visible board. */
@media (min-width: 901px) and (max-width: 1200px),
  (max-width: 900px) and (orientation: landscape) {
  :root {
    --cell: min(64px, calc((100dvh - 150px) / 10.6), calc((100vw - 360px) / 9));
  }

  .topbar {
    padding: 6px 12px 0;
    gap: 6px;
  }

  .brand {
    font-size: 22px;
  }
  .top-actions {
    gap: 4px;
  }
  .ghost-btn {
    font-size: 16px;
    padding: 6px 10px;
  }

  .layout {
    grid-template-columns: minmax(260px, 1fr) auto;
    grid-template-rows: minmax(0, 1fr) auto;
    height: auto;
    padding: 8px 12px;
  }

  .panel-wrap {
    grid-column: 1;
    grid-row: 1;
  }
  .board-column {
    grid-column: 2;
    grid-row: 1 / span 2;
    min-width: 0;
  }

  .screen-home .panel-body,
  .screen-lesson .panel-body,
  .screen-play .panel-body {
    justify-content: flex-start;
    padding-bottom: 0;
  }

  .ad-banner-panel,
  .character-stage {
    display: none;
  }

  .screen-play .character-stage,
  .screen-lesson .character-stage,
  .screen-play .character-stage:has(#play-clock-pc:not(.hidden)) {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    grid-column: 1;
    grid-row: 2;
    gap: 12px;
    padding: 0;
  }

  .character-stage > #char-gif {
    width: 60%;
    height: clamp(110px, 30dvh, 240px);
    max-height: none;
    object-fit: cover;
    object-position: center 40%;
  }
  #play-clock-pc {
    margin-top: 0;
  }
  #play-clock-pc .clock-cell {
    width: 48px;
  }
  #play-clock-pc .clock-num {
    font-size: 20px;
  }
  #play-clock-pc .clock-unit {
    font-size: 10px;
  }

  .speech,
  .speech.bad {
    grid-template-columns: minmax(0, 1fr);
  }
  .speech .mascot {
    display: none;
  }
  .bubble {
    font-size: 18px;
  }
  .board-wrap {
    padding: 4px;
  }
  .coord-files {
    margin-left: 4px;
  }
  .coord-ranks {
    margin-top: 4px;
  }
  .hand-row {
    min-height: 24px;
    gap: 4px;
  }
  .move-line {
    font-size: 16px;
    margin-top: 4px;
  }
  .ai-line {
    font-size: 13px;
  }
  .ai-line:empty {
    display: none;
  }
}

@media (max-width: 900px) and (orientation: portrait) {
  html,
  body {
    height: auto;
    min-height: 100%;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  html.menu-lock,
  html.menu-lock body {
    overflow: hidden;
    height: 100%;
  }

  .app-shell {
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 100svh;
    align-content: start;
    overflow: visible;
    grid-template-areas:
      "top"
      "main"
      "ad";
    grid-template-rows: auto auto auto;
  }

  :root {
    --char-min: 18vh;
    --banner-min: clamp(100px, 26vw, 160px);
    --wrap-pad: 4px;
    --rank-w: 16px;
    --board-size: min(
      calc(100vw - 16px),
      560px,
      max(280px, calc(100svh - 340px))
    );
    --cell: calc(
      (var(--board-size) - var(--rank-w) - 2 * var(--wrap-pad) - 2px) /
      9
    );
  }

  .bottom-slot {
    display: block;
    grid-area: ad;
  }

  .ad-banner-mobile {
    display: block;
    height: var(--banner-min);
    min-height: var(--banner-min);
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .lesson-dock {
    display: none;
    padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: var(--bg);
  }

  .screen-lesson .lesson-dock:not(.hidden) {
    display: block;
  }

  .lesson-prompt .speech {
    grid-template-columns: minmax(0, 1fr);
    margin: 0;
  }

  .lesson-prompt .mascot {
    display: none;
  }
  .lesson-prompt .bubble {
    padding: 8px 12px;
    min-height: 0;
    font-size: 16px;
  }
  .lesson-prompt .bubble::before {
    display: none;
  }

  .lesson-prompt .progress-note {
    margin: 0 0 6px;
    font-size: 16px;
  }

  .lesson-dock .lesson-nav {
    position: static;
    background: transparent;
    padding: 4px 0 0;
  }

  .ad-banner-panel {
    display: none;
  }

  .screen-home .panel-body {
    justify-content: flex-start;
    padding-bottom: 0;
  }

  .screen-lesson .layout,
  .screen-play .layout {
    height: auto;
    grid-template-areas: "board";
    grid-template-rows: auto;
  }

  .screen-lesson .character-stage {
    display: none;
  }

  .screen-play .topbar {
    background: transparent;
  }

  .screen-play .layout {
    grid-template-areas: "char" "board";
    grid-template-rows: auto auto;
  }

  .screen-play .character-stage,
  .screen-play .character-stage:has(#play-clock-pc:not(.hidden)) {
    display: flex;
    min-height: 0;
    height: calc(var(--char-min, 18vh) + 48px);
    margin: -48px 0 0;
    padding: 0;
    align-items: center;
    justify-content: center;
  }

  .screen-play .character-stage > #char-gif,
  .screen-play .character-stage:has(#play-clock-pc:not(.hidden)) > #char-gif {
    width: min(100%, 560px);
    height: 100%;
    max-height: none;
    object-fit: cover;
    object-position: center 45%;
  }

  .screen-lesson .lesson-prompt {
    display: block;
    width: 100%;
    max-height: 110px;
    overflow-y: auto;
    overscroll-behavior: contain;
    margin: 6px 0;
    padding: 8px;
    background: #fff;
    border-radius: 12px;
  }

  .screen-lesson .move-line,
  .screen-play .move-line {
    font-size: 16px;
    margin-top: 4px;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    flex-wrap: nowrap;
    padding: 8px 10px 0;
  }

  .app-shell.menu-open .topbar {
    background: transparent;
    pointer-events: none;
  }

  .app-shell.menu-open .brand {
    opacity: 0;
    pointer-events: none;
  }

  .app-shell.menu-open .hamburger {
    pointer-events: auto;
  }

  .brand {
    font-size: 22px;
  }

  .topbar > .top-actions {
    display: none;
  }

  .hamburger {
    display: flex;
    width: 44px;
    height: 44px;
    margin-left: auto;
    border: 0;
    border-radius: 12px;
    background: #fff;
    padding: 11px 10px;
    flex-direction: column;
    justify-content: space-between;
    flex-shrink: 0;
    position: relative;
    z-index: 41;
  }

  .hamburger span {
    display: block;
    height: 3px;
    background: var(--ink);
    border-radius: 99px;
    transition:
      transform 0.2s ease,
      opacity 0.2s ease;
  }

  .hamburger.is-open span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
  }

  .hamburger.is-open span:nth-child(2) {
    opacity: 0;
  }

  .hamburger.is-open span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
  }

  .ghost-btn {
    padding: 5px 10px;
    font-size: 16px;
  }

  .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "char"
      "board";
    grid-template-rows: var(--char-min, 18vh) auto;
    justify-items: stretch;
    align-items: stretch;
    overflow: visible;
    gap: 0;
    padding: 0 0 6px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .character-stage {
    grid-area: char;
    width: 100%;
    max-width: 100%;
    min-height: 168px;
    height: calc(var(--char-min, 18vh) + 48px);
    max-height: none;
    aspect-ratio: auto;
    margin-top: -48px;
    padding: 0;
    align-self: stretch;
    overflow: hidden;
    align-items: stretch;
    justify-content: stretch;
  }

  .character-stage > #char-gif {
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: cover;
    object-position: center 45%;
  }

  #play-clock-pc {
    display: none !important;
  }

  #play-clock-mobile:not(.hidden) {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    padding: 6px 12px calc(8px + env(safe-area-inset-bottom, 0px));
    background: var(--bg);
  }

  #play-clock-mobile .clock-cell {
    width: 56px;
  }

  #play-clock-mobile .clock-num {
    font-size: 23px;
  }

  #play-clock-mobile .clock-unit {
    font-size: 11px;
  }

  .board-column {
    grid-area: board;
    width: var(--board-size);
    margin-inline: auto;
    max-width: 100%;
    min-width: 0;
    min-height: 0;
    justify-content: center;
    overflow: visible;
  }

  .board-shell {
    width: 100%;
    max-width: 100%;
    margin-inline: auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .ai-line:empty {
    display: none;
  }

  .coord-files {
    width: calc(100% - var(--rank-w));
    margin: 0 0 4px;
    padding: 0 var(--wrap-pad);
    box-sizing: border-box;
    grid-template-columns: repeat(9, 1fr);
  }

  .board-mid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--rank-w);
    position: relative;
    width: 100%;
    max-width: 100%;
  }

  .board-wrap {
    width: 100%;
    min-width: 0;
    padding: var(--wrap-pad);
    box-sizing: border-box;
  }

  .board {
    width: 100%;
    aspect-ratio: 1;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
  }

  .coord-ranks {
    position: static;
    width: var(--rank-w);
    min-width: var(--rank-w);
    max-width: var(--rank-w);
    height: calc(100% - 2 * var(--wrap-pad) - 2px);
    margin-top: calc(var(--wrap-pad) + 1px);
    padding-left: 0;
    font-size: 12px;
    pointer-events: none;
    z-index: 1;
    grid-template-rows: repeat(9, 1fr);
  }

  .hand-row {
    width: 100%;
    max-width: 100%;
    background: var(--board);
    box-sizing: border-box;
    padding: 2px 0;
    min-height: 26px;
    gap: 4px;
  }

  .hand-row.gote {
    margin-bottom: 0;
  }

  .hand-row.sente {
    margin-top: 0;
  }

  .panel-wrap {
    display: none;
  }

  .panel-wrap.is-open {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 30;
    width: 100%;
    max-width: 100%;
    min-height: 100dvh;
    background: var(--bg);
    padding: 16px 16px 28px;
    overflow: hidden;
    align-self: stretch;
  }

  .panel-dialog-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
    min-height: 44px;
    padding-right: 52px;
  }

  .panel-dialog-bar strong {
    font-size: 24px;
    letter-spacing: 0.04em;
  }

  .top-actions.panel-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex-shrink: 0;
    margin: 14px 0 16px;
  }

  .panel-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .speech {
    grid-template-columns: 1fr 72px;
  }

  .mascot {
    width: 72px;
    height: 92px;
  }

  .screen-lesson .lesson-nav,
  .screen-play .lesson-nav {
    position: sticky;
    bottom: 0;
    z-index: 2;
    background: var(--bg);
    padding: 6px 0 2px;
  }
}

html[lang="zh-CN"] {
  --ui:
    "LXGW WenKai Lite", "Klee One", "Microsoft YaHei", "PingFang SC", sans-serif;
}

html[lang="zh-CN"] .bubble {
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.lang-switch[data-lang="zh-CN"] {
  grid-column: 1 / -1;
  font-family:
    "LXGW WenKai Lite", "Klee One", "Microsoft YaHei", "PingFang SC", sans-serif;
}

.banner-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  width: 100%;
  aspect-ratio: 1360 / 700;
  padding: 16px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--ink);
  text-align: center;
  line-height: 1.5;
}

.banner-copy strong {
  font-size: clamp(19px, 1.7vw, 27px);
}

.banner-copy > span {
  font-size: 16px;
}

@media (max-width: 900px) and (orientation: portrait) and (min-height: 800px) {
  .screen-lesson .layout {
    grid-template-areas: "char" "board";
    grid-template-rows: auto auto;
  }
  .screen-lesson .character-stage {
    display: flex;
    height: 90px;
    min-height: 0;
    margin: 0;
    align-items: center;
    justify-content: center;
  }
  .screen-lesson .character-stage > #char-gif {
    width: min(100%, 560px);
    height: 100%;
    max-height: none;
    object-fit: cover;
    object-position: center 45%;
  }
}

.banner-copy b {
  padding: 3px 14px;
  border-radius: 999px;
  background: var(--good-bg);
  font-size: 16px;
}

@media (max-width: 900px) and (orientation: portrait) {
  .ad-banner-mobile .banner-copy {
    height: 100%;
    aspect-ratio: auto;
    gap: 2px;
    padding: 6px 12px;
    border-radius: 8px;
  }

  .ad-banner-mobile .banner-copy strong {
    font-size: 18px;
  }

  .ad-banner-mobile .banner-copy > span,
  .ad-banner-mobile .banner-copy b {
    font-size: 13px;
  }
}
