/*
수정 시 주의사항
- 공통 스타일과 작은 화면의 배치.
- 언어에 따라 글자 길이가 달라집니다. 버튼 높이를 고정하거나 텍스트를 잘라내지 말고 줄바꿈을 허용하세요.
- 320·375·768·1280px 폭에서 4개 언어의 메뉴·설정·게임·튜토리얼을 확인하세요. 카드 안의 숫자 배치는 별도로 확인하세요.
- 기존 선택자를 뒤에서 재정의하는 규칙이 있습니다. 수정 시 같은 선택자의 다른 선언과 미디어 쿼리도 검색하세요.
*/
:root {
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    "Malgun Gothic",
    sans-serif;
  color: #212927;
  background: #f3f1eb;
  font-synthesis: none;
  --green: #234c3f;
  --red: #b53736;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select {
  font: inherit;
}
button {
  cursor: pointer;
  border: 0;
  border-radius: 9px;
  background: var(--green);
  color: white;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 650;
  transition:
    box-shadow 0.15s,
    background 0.15s;
}
button:hover:enabled {
  box-shadow: 0 0 0 3px #234c3f22;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid #cba74a;
  outline-offset: 3px;
}
button:disabled {
  cursor: default;
  opacity: 0.45;
}
.secondary {
  background: #e6e9e3;
  color: #33413a;
}
main {
  max-width: 1240px;
  margin: auto;
  padding: 40px 30px 24px;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 26px;
}
.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #65716a;
  margin: 0 0 10px;
}
h1 {
  font-size: 38px;
  letter-spacing: -0.05em;
  line-height: 1.15;
  margin: 0;
}
h1 span {
  font-size: 18px;
  vertical-align: middle;
  background: #dce8df;
  color: var(--green);
  border-radius: 7px;
  padding: 4px 8px;
  margin-left: 4px;
}
.intro {
  font-size: 14px;
  color: #69726c;
  margin: 12px 0 0;
}
.setup {
  display: flex;
  gap: 14px;
  align-items: end;
  padding: 18px;
  border: 1px solid #dddcd3;
  background: #faf9f5;
  border-radius: 13px;
  margin-bottom: 24px;
}
.setup label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12px;
  color: #627067;
  flex: 1;
}
.setup select,
.setup input {
  padding: 10px 12px;
  border: 1px solid #d2d7ce;
  background: white;
  border-radius: 8px;
  min-width: 0;
  color: #2f3c35;
}
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 28px;
}
.status {
  background: #e2ebe2;
  padding: 15px 18px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  min-height: 52px;
  line-height: 1.45;
}
.board-frame {
  padding: 20px 28px 24px 12px;
  background: #e0e3da;
  border-radius: 15px;
  margin: 18px 0;
}
.coordinates {
  color: #778277;
  font-size: 11px;
  text-align: center;
}
.top-coordinates {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  margin-left: 22px;
  margin-bottom: 10px;
}
.board-row {
  display: flex;
  gap: 10px;
}
.side-coordinates {
  display: grid;
  grid-template-rows: repeat(5, 1fr);
  width: 12px;
  align-items: center;
}
.board {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}
.cell {
  aspect-ratio: 1;
  min-width: 0;
  max-height: 112px;
  background: #f9faf6;
  border: 1px solid #d0d6c9;
  border-radius: 9px;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8d9a8b;
  font-size: 16px;
  position: relative;
}
.cell.occupied {
  background: #fff;
  border-color: #bac4b7;
}
.cell.anchor {
  outline: 3px solid #ba9445;
  outline-offset: -3px;
  background: #fff8e5;
}
.cell.drafted {
  background: #e7f2e3;
  border: 2px dashed #557653;
}
.cell.recommended {
  outline: 3px solid #6b92ad;
  outline-offset: -4px;
}
.cell:disabled {
  opacity: 1;
}
.card {
  background: white;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px solid #cbd0c6;
  border-radius: 8px;
  min-width: 49px;
  height: 67px;
  padding: 8px;
  color: #222a27;
}
.card .symbol {
  font-size: 27px;
  line-height: 1;
}
.card .num {
  font-size: 19px;
  font-weight: 800;
  position: absolute;
  bottom: 6px;
  right: 7px;
}
.card.red {
  color: var(--red);
  border-color: #d6b7b4;
}
.card.joker {
  background: #f6edd6;
  color: #8b6c20;
  border-color: #ccb777;
}
.card.joker .symbol {
  font-size: 22px;
}
.card.joker .num {
  font-size: 9px;
  left: 0;
  right: 0;
  bottom: 5px;
  letter-spacing: 0.02em;
  text-align: center;
}
.card.selected {
  outline: 3px solid #b58d36;
  outline-offset: 1px;
  background: #fffae8;
}
.cell .card {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  min-width: 0;
}
.cell .card .symbol {
  font-size: clamp(22px, 4vw, 42px);
}
.cell .card .num {
  font-size: clamp(18px, 2.7vw, 28px);
  bottom: 6px;
  right: 8px;
}
.cell .card.joker .num {
  font-size: 10px;
}
.controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.instruction {
  font-size: 13px;
  line-height: 1.7;
  color: #627166;
  min-height: 22px;
  margin: 12px 0 0;
}
.message {
  color: #ac3d30;
  min-height: 20px;
  font-size: 13px;
  margin: 5px 0 13px;
}
.hands {
  display: grid;
  gap: 14px;
}
.hand-panel {
  border: 1px solid #d7dad1;
  border-radius: 12px;
  background: #fafbf7;
  padding: 17px;
}
.hand-panel.active {
  border-color: #88a189;
  box-shadow: inset 3px 0 0 #456947;
}
.hand-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 13px;
}
.hand-heading h2 {
  margin: 0;
  font-size: 15px;
}
.hand-heading h2 small {
  font-size: 11px;
  font-weight: 400;
  color: #788277;
  margin-left: 7px;
}
.hand-heading > span {
  font-size: 12px;
  color: #788277;
}
#red h2 {
  color: var(--red);
}
.hand {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}
.hand .card:disabled {
  opacity: 0.8;
}
aside section {
  border-top: 1px solid #d9ddd2;
  padding: 20px 0;
}
.rules {
  padding-top: 4px;
  border-top: 0;
}
aside h2 {
  font-size: 15px;
  margin: 0 0 15px;
}
aside p,
aside ol {
  font-size: 13px;
  line-height: 1.85;
  color: #5a685d;
}
aside ol {
  padding-left: 20px;
}
aside li {
  padding-bottom: 7px;
}
aside p strong {
  color: #313e32;
}
.muted {
  color: #839080 !important;
  font-size: 12px !important;
}
.history ol {
  max-height: 245px;
  overflow: auto;
  list-style: none;
  padding: 0;
}
.history li {
  padding: 8px 0;
  border-bottom: 1px solid #e3e5dd;
  font-size: 12px;
  line-height: 1.6;
}
.history .turn-label {
  font-weight: 700;
  color: #314133;
}
.history .turn-label.red {
  color: var(--red);
}
a {
  color: var(--green);
  font-size: 13px;
}
footer {
  font-size: 11px;
  color: #90998b;
  border-top: 1px solid #daddd3;
  margin-top: 28px;
  padding-top: 16px;
}
@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 245px;
    gap: 18px;
  }
  main {
    padding: 26px 18px;
  }
  .setup {
    gap: 9px;
  }
  .board-frame {
    padding-right: 16px;
  }
}
@media (max-width: 700px) {
  .layout {
    grid-template-columns: 1fr;
  }
  header {
    align-items: flex-start;
  }
  h1 {
    font-size: 31px;
  }
  .intro {
    font-size: 12px;
    max-width: 230px;
  }
  .setup {
    flex-wrap: wrap;
    padding: 13px;
  }
  .setup label {
    flex: 1 1 40%;
  }
  .setup label:last-child {
    flex-basis: 100%;
  }
  .board-frame {
    max-width: 520px;
    margin: 16px auto;
  }
  .board {
    gap: 6px;
  }
  .controls button {
    font-size: 12px;
    padding: 11px 12px;
  }
  .hand-panel {
    padding: 13px;
  }
  .hand-heading {
    flex-wrap: wrap;
  }
  .card {
    min-width: 46px;
    height: 62px;
  }
  aside {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
  }
  .rules {
    border-top: 1px solid #d9ddd2;
    padding-top: 20px;
  }
  main {
    padding: 22px 14px;
  }
}

.cell.arriving .card {
  animation: card-land 0.4s ease-out;
}
.cell.clearing {
  background: #f5d988;
  box-shadow: inset 0 0 0 3px #b98926;
}
.cell.clearing .card {
  animation: line-glow 0.65s ease-in-out infinite alternate;
}
@keyframes card-land {
  from {
    transform: translateY(-18px) scale(0.8);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}
@keyframes line-glow {
  to {
    transform: scale(0.9);
    opacity: 0.5;
  }
}
[hidden] {
  display: none !important;
}
@media (prefers-reduced-motion: reduce) {
  .cell.arriving .card,
  .cell.clearing .card {
    animation: none;
  }
}

.cell:disabled {
  opacity: 1;
}

.selection {
  padding: 12px 14px;
  background: #edf1e8;
  border-radius: 9px;
  font-size: 14px;
  margin-top: 14px;
}
.cell.valid-target {
  background: #d7ead0;
  box-shadow: inset 0 0 0 3px #508258;
}
.cell.valid-target::after {
  content: "여기에 놓기";
  font-size: 10px;
  color: #315336;
}
.hand .unplayable {
  opacity: 0.45;
}
.hands {
  display: flex;
  flex-direction: column;
}
.hand-panel.active {
  order: -1;
  border: 2px solid #789777;
}
.controls {
  position: sticky;
  bottom: 0;
  background: #f3f1ebee;
  padding: 12px 0;
  z-index: 2;
}
.controls #confirm {
  flex: 1;
}
.controls #draw {
  background: #dee7f1;
  color: #294763;
}
.hand .selected {
  outline: 3px solid #bb8d31;
  outline-offset: 2px;
}

.opponent-panel {
  margin-top: 16px;
}
.opponent-panel summary {
  cursor: pointer;
  font-size: 13px;
  color: #58695d;
  padding: 10px 0;
}
.opponent-panel .hand-panel {
  background: #ecefe8;
}
.hand-panel .hand {
  margin-top: 10px;
}

.cell.ghosted .card {
  opacity: 0.48;
  pointer-events: none;
}
.cell.valid-target::after {
  content: none;
}
.hand .card {
  position: relative;
}
.order-badge {
  position: absolute;
  right: -4px;
  top: -5px;
  border-radius: 50%;
  background: #bb8d31;
  color: white;
  font-size: 11px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
}
.direction-control {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  margin-top: 12px;
}
.direction-control select {
  padding: 8px;
  border-radius: 7px;
  border: 1px solid #b7c3b0;
}

.hand .just-drawn {
  box-shadow: 0 0 0 3px #508258;
  background: #e6f4df;
}

.hand-panel.active .card:disabled {
  opacity: 0.3;
}
.hand-panel.active .card:enabled {
  box-shadow: 0 0 0 1px #86a776;
}

.layout {
  grid-template-columns: minmax(0, 1fr) 390px;
  align-items: start;
}
.hand-rail {
  min-width: 0;
}
.hand-rail .hands {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.hand-rail .hand-panel {
  order: 0 !important;
  margin: 0;
  border: 1px solid #cbd5c8;
  padding: 16px;
}
.hand-rail .hand-panel.active {
  border: 2px solid #789777;
}
.hand-rail .hand {
  max-height: 340px;
  overflow: auto;
  padding: 5px 3px;
}
.panel-tools {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.panel-tools button {
  flex: 1;
}
.hand .just-drawn {
  box-shadow: 0 0 0 2px #8cba9380 !important;
  background: #edf5e8;
}
.hand .action-selected {
  opacity: 1 !important;
  outline: 3px solid #c39939;
  outline-offset: 2px;
  background: #fff4d3;
}
.cell.action-anchor {
  box-shadow: inset 0 0 0 4px #c39939;
  background: #f6e6b9;
}
dialog {
  width: min(560px, calc(100% - 28px));
  max-height: 80vh;
  overflow: auto;
  border: 1px solid #cad4c5;
  border-radius: 16px;
  background: #fafbf7;
  color: #263a2d;
  padding: 24px;
}
dialog::backdrop {
  background: #172b2466;
}
dialog section {
  padding: 12px 0;
}
dialog .history ol {
  max-height: none;
}
dialog p,
dialog li {
  font-size: 14px;
  line-height: 1.8;
}
.dialog-close {
  display: block;
  margin-left: auto;
  background: #e3eadf;
  color: #314535;
}
.hand-heading > span {
  line-height: 1.6;
}
.controls {
  position: static;
}
.hand-panel.active .just-drawn:disabled {
  opacity: 0.8;
}
@media (max-width: 1000px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 310px;
  }
  .hand-rail .card {
    min-width: 40px;
    height: 55px;
  }
  .hand-rail .hand-panel {
    padding: 12px;
  }
}
@media (max-width: 760px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .hand-rail {
    display: block;
  }
  .hand-rail .hands {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .hand-rail .hand {
    max-height: 240px;
  }
  .hand-heading {
    gap: 7px;
  }
  .hand-heading > span {
    font-size: 11px;
  }
}
@media (max-width: 440px) {
  .hand-rail .hands {
    grid-template-columns: 1fr;
  }
}

.hand-rail .controls {
  gap: 7px;
  margin: 8px 0;
}
.hand-rail .controls button {
  font-size: 12px;
  padding: 10px 11px;
}
.hand-rail .selection {
  font-size: 12px;
  line-height: 1.7;
}
.hand-rail .instruction {
  font-size: 12px;
}
.hand-rail .direction-control {
  flex-wrap: wrap;
}

.card.x-card {
  background: #426a62;
  color: #fff;
  border: 2px solid #274c45;
}
.x-card .symbol {
  font-size: 2.2rem;
}
.x-card .num {
  font-size: 0.56rem;
  letter-spacing: 0.12em;
}
.cell.x-cell {
  background: #dce7df;
}
.x-status {
  margin: 0.4rem 0;
  color: #41675c;
  font-size: 0.8rem;
  line-height: 1.5;
}
#move-x.selected {
  background: #d9ebdc;
  border-color: #42855c;
}
.cell.drafted .x-card {
  opacity: 0.55;
}
.cell.valid-target .x-card {
  opacity: 0.4;
}

.card.x-card {
  background: #fff;
  color: #111;
  border: 0;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.x-card .symbol {
  font-family: Arial, sans-serif;
  font-weight: 800;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1;
}
.x-card .num {
  display: none;
}
.cell.x-cell {
  background: #fff;
}
.cell.valid-target.x-preview {
  background: #f5f5f5;
  border-color: #c5c5c5;
  box-shadow: none;
}
.cell.x-preview .x-card,
.cell.drafted .x-card {
  background: #fff;
  color: #b9b9b9;
  opacity: 0.55;
}
.cell.x-preview .x-card .symbol,
.cell.drafted .x-card .symbol {
  color: #b9b9b9;
}
.menu {
  max-width: 650px;
  margin: 70px auto 100px;
}
.menu h2 {
  font-size: clamp(28px, 5vw, 46px);
  letter-spacing: -0.04em;
  line-height: 1.3;
}
.menu p {
  color: #65716a;
  line-height: 1.8;
}
.menu-buttons {
  display: grid;
  gap: 12px;
  margin-top: 32px;
  max-width: 390px;
}
.menu-buttons button {
  text-align: left;
  padding: 20px;
  font-size: 17px;
}
.game-nav {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 18px;
}
.help-page {
  max-width: 760px;
  line-height: 1.9;
  margin: 30px auto;
}
.record-row {
  display: block;
  width: 100%;
  text-align: left;
  margin: 12px 0;
  line-height: 1.7;
}
#setup-error,
#record-error {
  color: #b53736;
}
#new {
  display: none;
}
header {
  justify-content: center;
  margin: 45px 0 20px;
}
header h1 {
  font-size: 42px;
}
.menu {
  margin: 35px auto 100px;
  text-align: center;
}
.menu-buttons {
  margin: 25px auto;
}
.menu-buttons button {
  text-align: center;
}
.record-tools {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 20px 0;
}
footer[data-footer] {
  text-align: center;
}
.setup input[type="hidden"] {
  display: none;
}
.record-pages {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 25px 0;
}
.record-pages button[aria-current="page"] {
  background: var(--green);
  color: white;
  opacity: 1;
}
.record-pages span {
  padding: 5px;
}
[data-screen="mode"] h2 {
  font-size: 24px;
  line-height: 1.35;
}
.seed-disabled {
  opacity: 0.48;
}
.seed-disabled input {
  background: #e6e9e3;
  cursor: default;
}
.record-item {
  display: flex;
  align-items: center;
  gap: 12px;
}
.record-item > input {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  accent-color: var(--green);
}
.record-item .record-row {
  flex: 1;
  min-width: 0;
}
.help-menu-title {
  font-size: 24px !important;
}
.learning-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 0;
}
.rulebook {
  max-width: 900px;
  margin: 30px auto;
  font-size: 15px;
  line-height: 1.9;
}
.rulebook-title {
  font-size: 28px;
}
.rule-section {
  border-top: 1px solid #d9ddd2;
  padding: 24px 0;
  scroll-margin-top: 25px;
}
.rule-section h2 {
  font-size: 22px;
  margin: 0 0 18px;
}
.rule-section h3 {
  font-size: 17px;
  margin: 22px 0 12px;
}
.rulebook p {
  margin: 12px 0;
}
.rulebook li {
  margin: 8px 0;
}
.rule-toc {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 15px;
  background: #e6e9e3;
  border-radius: 10px;
}
.rule-toc a {
  font-size: 14px;
  text-decoration: none;
  padding: 4px 8px;
}
.rule-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}
.rule-board {
  max-width: 390px;
  margin: 22px 0;
  gap: 5px;
}
.rule-board .cell {
  min-height: 40px;
  max-height: 72px;
}
.rule-board .symbol {
  font-size: 25px !important;
}
.rule-board .num {
  font-size: 17px !important;
}
.rule-complete {
  background: #fff3cf !important;
  border-color: #b78c33 !important;
}
.rule-sequence {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 15px 0;
}
.rule-card-examples {
  padding: 5px 0;
}
.rulebook table {
  border-collapse: collapse;
  width: 100%;
  margin: 18px 0;
  font-size: 14px;
}
.rulebook th,
.rulebook td {
  border: 1px solid #d4dacd;
  padding: 12px;
  text-align: left;
}
.rulebook th {
  background: #e6e9e3;
}
.tutorial-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 28px;
  align-items: start;
}
.tutorial-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
}
.tutorial-heading h2 {
  font-size: 24px;
}
.tutorial-heading > span {
  white-space: nowrap;
  font-size: 13px;
  color: #65716a;
}
.tutorial-rail {
  display: grid;
  gap: 14px;
}
.tutorial-rail h3 {
  font-size: 15px;
  margin: 0 0 12px;
}
.tutorial-guide-panel {
  background: #fffdf7;
  border: 1px solid #d8d4c7;
  border-radius: 12px;
  padding: 18px;
}
.tutorial-guide-panel p {
  font-size: 13px;
  line-height: 1.8;
  margin: 0 0 14px;
  color: #617069;
}
#tutorial-guide {
  font-size: 16px;
  line-height: 1.8;
  font-weight: 600;
  padding: 14px;
  background: #e7eee4;
  border-radius: 8px;
}
#tutorial-feedback {
  color: #a4332a;
  margin-top: 10px;
}
.tutorial-coordinate {
  position: absolute;
  top: 5px;
  left: 7px;
  font-size: 10px;
  color: #65716a;
  font-weight: 400;
}
.tutorial-target {
  outline: 3px solid #c49a35 !important;
  outline-offset: 3px;
  box-shadow: 0 0 0 6px #c49a3522 !important;
}
.tutorial-board-frame {
  padding: 16px;
}
.tutorial-controls {
  margin: 0;
  padding: 0;
}
.tutorial-chapters summary {
  cursor: pointer;
  font-size: 14px;
}
#tutorial-lesson-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}
#tutorial-lesson-list button {
  text-align: left;
  font-size: 12px;
}
#tutorial-lesson-list [aria-current="step"] {
  background: var(--green);
  color: white;
}
#tutorial-hand0 .card:disabled {
  opacity: 0.8;
}
#tutorial-next {
  margin-top: 16px;
  width: 100%;
}
@media (max-width: 850px) {
  .tutorial-layout {
    grid-template-columns: 1fr 310px;
    gap: 18px;
  }
  .rule-split {
    gap: 18px;
  }
}
@media (max-width: 700px) {
  .tutorial-layout,
  .rule-split {
    grid-template-columns: 1fr;
  }
  .tutorial-rail {
    display: flex;
    flex-direction: column;
  }
  .tutorial-guide-panel {
    order: -1;
  }
  .tutorial-heading h2 {
    font-size: 20px;
  }
  .rulebook {
    font-size: 14px;
  }
  .rulebook th,
  .rulebook td {
    padding: 8px;
  }
  .tutorial-layout {
    display: flex;
    flex-direction: column;
  }
  .tutorial-layout > section,
  .tutorial-rail {
    width: 100%;
  }
  .tutorial-board-frame {
    max-width: 440px;
    margin: 15px auto;
  }
  #tutorial-guide {
    font-size: 15px;
  }
  .tutorial-board-frame .cell {
    max-height: none;
  }
}
@media (max-width: 700px) {
  .tutorial-rail {
    display: contents;
  }
  .tutorial-guide-panel {
    order: -1;
    width: 100%;
  }
  .tutorial-layout > .tutorial-rail > section,
  .tutorial-layout > .tutorial-rail > .controls {
    width: 100%;
  }
}
/* Separate the symbol and number into their own rows at every card size. */
.card:not(.x-card) {
  display: inline-grid;
  grid-template-rows: minmax(0, 1fr) 18px;
  gap: 4px;
  padding: 6px;
  align-items: center;
  justify-items: center;
}
.card:not(.x-card) .symbol {
  font-size: 27px;
  line-height: 1;
  align-self: center;
}
.card:not(.x-card) .num {
  position: static;
  display: block;
  width: 100%;
  font-size: 18px;
  line-height: 1;
  text-align: right;
  align-self: end;
  font-variant-numeric: tabular-nums;
}
.card.joker .symbol {
  font-size: 22px;
}
.card.joker .num {
  font-size: 9px;
  text-align: center;
}
.cell .card:not(.x-card) {
  container-type: inline-size;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 3px;
  padding: 3px;
}
.cell .card:not(.x-card) .symbol {
  font-size: clamp(16px, 45cqw, 38px);
}
.cell .card:not(.x-card) .num {
  font-size: clamp(12px, 28cqw, 24px);
}
.cell .card.joker .symbol {
  font-size: clamp(16px, 34cqw, 26px);
}
.cell .card.joker .num {
  font-size: 9px;
  text-align: center;
}
@media (max-width: 1000px) {
  .hand-rail .card:not(.x-card) {
    grid-template-rows: minmax(0, 1fr) 16px;
    gap: 3px;
    padding: 4px;
  }
  .hand-rail .card:not(.x-card) .symbol {
    font-size: 22px;
  }
  .hand-rail .card:not(.x-card) .num {
    font-size: 16px;
  }
  .hand-rail .card.joker .num {
    font-size: 9px;
    text-align: center;
  }
}

.rule-example {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 15px 0;
}
.rule-example > .card,
.rule-sequence > .card {
  width: 49px;
  flex: 0 0 49px;
}
.tutorial-target {
  position: relative;
  overflow: visible;
  z-index: 3;
}
.tutorial-target::after {
  content: var(--tutorial-click);
  position: absolute;
  left: 50%;
  top: -29px;
  transform: translateX(-50%);
  padding: 4px 9px;
  border-radius: 7px;
  background: #234c3f;
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 5px #0002;
}
.tutorial-target::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -4px;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #234c3f;
  pointer-events: none;
}
#tutorial-hand0 {
  padding-top: 30px;
}
.tutorial-controls {
  row-gap: 36px;
  padding-top: 30px;
}
[data-screen="tutorial"] {
  overflow-anchor: none;
}

/* Board cards have their own layout; miniature cards keep separate rows. */
.cell .board-card:not(.x-card) {
  display: block;
  position: relative;
  padding: 0;
  gap: 0;
  container-type: inline-size;
}
.cell .board-card:not(.x-card) .symbol {
  position: absolute;
  inset: 8% 0 25%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(25px, 58cqw, 64px);
  line-height: 1;
}
.cell .board-card:not(.x-card) .num {
  position: absolute;
  right: 0;
  bottom: 0;
  width: auto;
  font-size: clamp(16px, 29cqw, 30px);
  line-height: 1;
  text-align: right;
}
.cell .board-card.joker .symbol {
  font-size: clamp(24px, 48cqw, 48px);
}
.cell .board-card.joker .num {
  font-size: 9px;
  left: 0;
  right: 0;
  text-align: center;
}
.rule-board .board-card .symbol {
  font-size: clamp(22px, 58cqw, 42px) !important;
}
.rule-board .board-card .num {
  font-size: clamp(14px, 29cqw, 22px) !important;
}
.menu-buttons button,
.menu-buttons button.secondary {
  background: #cfd8cd;
  color: #293c31;
}
.menu-buttons button:hover:enabled {
  background: #bdcbbb;
}

.bug-form {
  display: grid;
  gap: 14px;
}
.bug-form label {
  display: grid;
  gap: 7px;
  font-size: 14px;
}
.bug-form textarea {
  width: 100%;
  min-height: 160px;
  box-sizing: border-box;
  padding: 12px;
  border: 1px solid #cad4c5;
  border-radius: 8px;
  font: inherit;
}
.bug-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.ad-area {
  width: 100%;
  max-width: 970px;
  box-sizing: border-box;
  margin: 48px auto 24px;
  padding: 24px 12px 0;
  border-top: 1px solid #daddd3;
  text-align: center;
  color: #65716a;
  font-size: 12px;
  position: static;
  clear: both;
}
.ad-area .adsbygoogle {
  max-width: 100%;
}
@media (max-width: 700px) {
  .ad-area {
    margin-top: 40px;
    padding-top: 24px;
  }
}
.ad-area > small {
  display: block;
  margin-bottom: 8px;
}

.language-setting {
  display: grid;
  gap: 12px;
  margin: 22px 0;
}
.language-setting select {
  padding: 12px;
  border: 1px solid #cad4c5;
  border-radius: 9px;
  background: white;
  color: #263a2d;
  font: inherit;
  width: 100%;
}
.settings-note {
  color: #65716a;
  font-size: 13px;
  line-height: 1.7;
}

/* Language-safe layouts: controls wrap; the board keeps its dimensions. */
button:not(.card):not(.cell) {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.45;
  min-width: 0;
}
.menu-buttons button {
  min-height: 64px;
}
.learning-nav,
.game-nav,
.panel-tools,
.record-tools,
.hand-heading,
.tutorial-heading {
  flex-wrap: wrap;
}
.panel-tools button {
  flex: 1 1 110px;
}
.controls:not(.tutorial-controls) {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}
.controls #confirm {
  grid-column: 1/-1;
}
.controls button {
  min-height: 44px;
}
.direction-control select {
  max-width: 100%;
  min-width: 0;
  flex: 1 1 150px;
}
.hand-heading h2 {
  flex: 0 1 auto;
}
.hand-heading > span {
  flex: 1 1 120px;
  text-align: right;
  overflow-wrap: anywhere;
}
.status,
.selection,
.instruction,
.message,
.x-status,
.record-row,
dialog p,
.tutorial-guide-panel {
  overflow-wrap: anywhere;
}
.tutorial-heading > span {
  white-space: normal;
}
.rulebook table {
  table-layout: fixed;
}
.rulebook td,
.rulebook th {
  overflow-wrap: anywhere;
}
.record-item {
  min-width: 0;
}
.record-row {
  min-width: 0;
}
.bug-form,
.bug-form label {
  min-width: 0;
}
.bug-form textarea {
  max-width: 100%;
}
@media (max-width: 900px) {
  .tutorial-layout {
    grid-template-columns: 1fr;
  }
  .tutorial-rail {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .tutorial-guide-panel,
  .tutorial-controls,
  .tutorial-rail > .muted {
    grid-column: 1/-1;
  }
}
@media (max-width: 760px) {
  .hand-heading > span {
    text-align: left;
  }
  .direction-control {
    align-items: flex-start;
  }
  .direction-control select {
    flex-basis: 100%;
    width: 100%;
  }
  .setup label {
    min-width: 0;
  }
  .tutorial-layout {
    display: flex;
    flex-direction: column;
  }
  .tutorial-rail {
    display: contents;
  }
  .tutorial-guide-panel {
    order: -1;
    width: 100%;
  }
  .tutorial-layout > .tutorial-rail > section,
  .tutorial-layout > .tutorial-rail > .controls {
    width: 100%;
  }
  .tutorial-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tutorial-controls #tutorial-confirm,
  .tutorial-controls #tutorial-next {
    grid-column: 1/-1;
  }
}
@media (max-width: 440px) {
  .tutorial-heading h2 {
    font-size: 20px;
  }
  .learning-nav button {
    flex: 1 1 110px;
  }
  .record-tools button {
    flex: 1 1 130px;
  }
  .menu-buttons button {
    font-size: 16px;
  }
  .rulebook-title {
    font-size: 25px;
  }
}

/* Full translations: long labels must grow vertically without shrinking card cells. */
.learning-nav,
.game-nav,
.record-tools,
.panel-tools,
.controls {
  min-width: 0;
}
.learning-nav > button,
.game-nav > button,
.record-tools > button {
  max-width: 100%;
}
:lang(es) button:not(.card):not(.cell),
:lang(es) .rulebook {
  hyphens: auto;
}
:lang(ja) .rulebook,
:lang(ja) .tutorial-guide-panel {
  line-break: strict;
}

/* Non-clickable preview: approximate desktop/mobile banners, kept below game controls. */
.ad-preview-banner {
  box-sizing: border-box;
  width: 100%;
  max-width: 728px;
  min-height: 90px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed #8d9b90;
  border-radius: 8px;
  background: repeating-linear-gradient(
    135deg,
    #eef1ea,
    #eef1ea 12px,
    #e6ebe2 12px,
    #e6ebe2 24px
  );
  color: #4a594e;
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  cursor: default;
  pointer-events: none;
}
@media (max-width: 700px) {
  .ad-preview-banner {
    max-width: 320px;
    min-height: 100px;
  }
}
