:root {
  --ink: #071217;
  --night: #071b24;
  --navy: #0c2c38;
  --felt: #0c574c;
  --felt-light: #147161;
  --gold: #f2c45f;
  --gold-dark: #8f5a22;
  --red: #b63332;
  --cream: #fff5d5;
  --tile-w: clamp(38px, 4.65vw, 52px);
  --tile-h: calc(var(--tile-w) * 1.34);
  --pixel: "DotGothic16", "Yu Gothic", monospace;
  --serif: "Noto Serif JP", "Yu Mincho", serif;
}

* { box-sizing: border-box; }
html, body {
  width: 100%; min-height: 100%; margin: 0; background: #030b0f; color: var(--cream); overflow: hidden;
  text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
button { font: inherit; }
button:focus-visible { outline: 3px solid #fff06a; outline-offset: 3px; }
.hidden { display: none !important; }

body {
  font-family: var(--pixel);
  image-rendering: auto;
  background:
    radial-gradient(circle at 50% 35%, #123d48 0, #071820 45%, #020608 100%);
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: 1000; pointer-events: none; opacity: .07;
  background: repeating-linear-gradient(0deg, transparent 0 4px, rgba(0,0,0,.28) 4px 5px);
  mix-blend-mode: multiply;
}

#app, .screen { width: 100%; height: 100dvh; }
.screen { display: none; position: relative; overflow: hidden; }
.screen.active { display: block; animation: screen-in .38s steps(8); }
@keyframes screen-in { from { opacity: 0; filter: brightness(2); } to { opacity: 1; filter: none; } }

/* ---------- Title ---------- */
#title-screen {
  background:
    linear-gradient(90deg, rgba(255,255,255,.025) 50%, transparent 50%) 0 0/8px 8px,
    radial-gradient(ellipse at 50% 21%, rgba(44,137,144,.52), transparent 36%),
    linear-gradient(#061b26 0 45%, #071116 72%);
}
.title-sky { position: absolute; inset: 0; overflow: hidden; }
.title-sky::before {
  content: ""; position: absolute; left: 50%; top: 8%; width: min(52vw, 520px); aspect-ratio: 1; transform: translateX(-50%);
  border: 3px solid rgba(241,196,95,.13); border-radius: 50%;
  box-shadow: 0 0 0 22px rgba(241,196,95,.025), 0 0 80px rgba(73,212,187,.13);
}
.title-sky::after {
  content: ""; position: absolute; left: -5%; right: -5%; bottom: 0; height: 31%;
  background:
    linear-gradient(135deg, transparent 0 46%, #0b2930 47% 54%, transparent 55%) 0 0/160px 110px,
    linear-gradient(45deg, transparent 0 46%, #0a242a 47% 54%, transparent 55%) 40px 0/180px 115px,
    linear-gradient(#0b252c, #02090c);
  border-top: 3px solid #1b4f50;
}
.title-sky i { position: absolute; width: 5px; height: 5px; background: #d6e6c3; box-shadow: 0 0 7px #fff; animation: star 2.4s steps(2) infinite; }
.title-sky i:nth-child(1) { top: 15%; left: 15%; }
.title-sky i:nth-child(2) { top: 26%; right: 19%; animation-delay: .6s; }
.title-sky i:nth-child(3) { top: 48%; left: 11%; animation-delay: 1.2s; }
.title-sky i:nth-child(4) { top: 10%; right: 10%; animation-delay: 1.8s; }
@keyframes star { 50% { opacity: .2; transform: scale(.6); } }

.title-frame {
  position: relative; z-index: 2; width: min(700px, calc(100% - 28px)); min-height: 100%; margin: 0 auto;
  padding: clamp(12px, 2vh, 24px) 0 44px; display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.series-label { margin: 0 0 3px; color: #7eaaa8; font-size: 11px; letter-spacing: .4em; }
.title-emblem {
  position: absolute; top: max(22px, 5vh); left: 8%; width: 58px; height: 58px; padding: 5px; transform: rotate(-8deg);
  border: 2px solid #d69b50; color: #d69b50; opacity: .76;
}
.title-emblem::before { content: ""; position: absolute; inset: 4px; border: 1px solid #d69b50; }
.title-emblem span { position: relative; display: grid; height: 100%; place-items: center; font: 900 31px var(--serif); }
h1 { position: relative; margin: 0 0 1px; height: clamp(92px, 17vh, 145px); width: 100%; text-align: center; line-height: .88; }
h1 small { display: block; margin-bottom: 2px; color: #bcd5cf; font: 11px var(--pixel); letter-spacing: .8em; text-indent: .8em; }
h1 span {
  display: inline-block; color: #e5f1df; font: 900 clamp(44px, 8vh, 73px) var(--serif); letter-spacing: -.08em;
  text-shadow: 3px 3px 0 #133f43, 6px 6px 0 #02090c, 0 0 20px rgba(255,255,255,.15);
}
h1 strong {
  display: inline-block; margin-left: .12em; color: var(--gold); font: 900 clamp(42px, 7.5vh, 69px) var(--serif); letter-spacing: -.08em;
  text-shadow: 2px 2px 0 #9c4c2c, 5px 5px 0 #4a1e19, 7px 7px 0 #02090c;
}
.title-copy { margin: 0 0 clamp(9px, 2vh, 18px); color: #9fc5bd; font: 700 clamp(11px, 1.6vh, 14px) var(--serif); letter-spacing: .24em; }

.mode-grid { width: min(590px, 96%); display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode-card {
  position: relative; min-height: clamp(58px, 8.7vh, 76px); padding: 7px 34px 7px 8px; display: flex; align-items: center; gap: 10px; cursor: pointer;
  color: #e9f4e8; background: linear-gradient(180deg, #194a50, #0b2d35); border: 2px solid #3c7774; border-radius: 3px;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,.08), inset -3px -3px 0 rgba(0,0,0,.28), 4px 4px 0 #02090c;
  transition: transform .08s, filter .08s;
}
.mode-card:hover, .mode-card.selected { filter: brightness(1.28); transform: translate(-1px,-1px); border-color: #80c2b6; }
.mode-card:active { transform: translate(3px,3px); box-shadow: inset 2px 2px 0 rgba(0,0,0,.3); }
.mode-card.primary { background: linear-gradient(180deg, #995032, #63291f); border-color: #d69b50; }
.mode-card.gold { background: linear-gradient(180deg, #66501f, #34280f); border-color: #d5ae4f; }
.mode-card > i {
  position: absolute; right: 4px; top: 4px; bottom: 4px; width: 24px; display: grid; place-items: center;
  color: #e9ce7f; border-left: 1px solid rgba(255,255,255,.17); font-style: normal; font-size: 10px; writing-mode: vertical-rl; letter-spacing: .15em;
}
.mode-icon {
  flex: 0 0 40px; width: 40px; height: 40px; display: grid; place-items: center; color: #e8c578; background: #071a20;
  border: 1px solid #ad8650; box-shadow: inset 0 0 0 3px #102e31; font: 900 23px var(--serif);
}
.mode-body { min-width: 0; display: flex; flex-direction: column; text-align: left; }
.mode-body b { font: 700 clamp(14px, 2vh, 18px) var(--serif); letter-spacing: .08em; }
.mode-body small { color: #9fc3be; font-size: 10px; white-space: nowrap; }
.title-actions { display: flex; gap: 10px; margin-top: clamp(8px, 1.5vh, 14px); }
.subtle-btn, .hud-actions button, #learn-back-btn {
  padding: 6px 15px; color: #a9c9c4; background: #07161c; border: 1px solid #426968; box-shadow: 2px 2px 0 #000; cursor: pointer;
}
.subtle-btn:hover { color: #fff; border-color: var(--gold); }
.title-controls { margin: 8px 0 0; color: #607e7c; font-size: 10px; }
.title-disclaimer {
  width: min(640px, 96%); margin: clamp(6px, 1vh, 10px) 0 0; padding: 6px 10px;
  color: #698b87; background: rgba(3, 15, 19, .74); border: 1px solid #294b4b;
  box-shadow: inset 0 0 0 1px rgba(166, 141, 88, .08); font-size: clamp(7px, 1.15vh, 9px); line-height: 1.42; text-align: center;
}
.title-disclaimer b { display: block; margin-bottom: 2px; color: #a68d58; font-weight: 400; letter-spacing: .14em; }
.title-disclaimer span { display: block; }
.title-footer { position: absolute; z-index: 3; bottom: 9px; left: 16px; right: 16px; display: flex; justify-content: space-between; color: #416564; font-size: 9px; }

/* ---------- Game table ---------- */
#game-screen { background: #03090d; }
.game-hud {
  position: relative; z-index: 20; height: 48px; display: grid; grid-template-columns: 180px 1fr 255px; align-items: center;
  padding: 0 10px; background: linear-gradient(#17313a, #08161c); border-bottom: 3px solid #8c5b28; box-shadow: 0 3px 0 #020507;
}
.round-plate { display: flex; align-items: baseline; gap: 7px; }
.round-plate span { color: var(--gold); font: 900 20px var(--serif); text-shadow: 2px 2px #000; }
.round-plate small { color: #8eaaa8; font-size: 10px; }
.hud-center { display: flex; align-items: center; justify-content: center; gap: 14px; }
.hud-center b { color: #e9c476; font-size: 12px; }
.hud-center span { color: #b6cfca; font-size: 11px; }
.hud-actions { display: flex; justify-content: flex-end; gap: 5px; }
.hud-actions button { padding: 5px 8px; font-size: 10px; }
.hud-actions button.active { color: #251607; background: var(--gold); border-color: #fff0a1; box-shadow: 2px 2px 0 #5d2f1d; }

.table {
  position: relative; width: min(100%, 1280px); height: calc(100dvh - 48px); margin: 0 auto; overflow: hidden;
  background:
    radial-gradient(circle at 50% 47%, rgba(44,155,127,.35), transparent 36%),
    repeating-linear-gradient(45deg, rgba(255,255,255,.012) 0 2px, transparent 2px 7px),
    linear-gradient(135deg, #0a4b42, #073b36);
  border: clamp(5px, .8vw, 10px) solid #5b351d;
  box-shadow: inset 0 0 0 4px #17110c, inset 0 0 45px rgba(0,0,0,.68);
}
.felt-pattern { position: absolute; inset: 10px; opacity: .12; pointer-events: none; }
.felt-pattern::before, .felt-pattern::after { content: ""; position: absolute; border: 2px solid #7cc5ad; transform: rotate(45deg); }
.felt-pattern::before { width: 260px; height: 260px; left: calc(50% - 130px); top: calc(48% - 130px); }
.felt-pattern::after { width: 210px; height: 210px; left: calc(50% - 105px); top: calc(48% - 105px); }

.seat { position: absolute; z-index: 4; }
.seat-top { left: 25%; right: 25%; top: 8px; text-align: center; }
.seat-left { left: 10px; top: 17%; bottom: 28%; width: 150px; }
.seat-right { right: 10px; top: 17%; bottom: 28%; width: 150px; }
.opponent-info {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 7px; color: #d1e1d9; background: rgba(3,18,18,.86);
  border: 1px solid #6c8d78; box-shadow: 2px 2px #00201c; font-size: 10px;
}
.opponent-info .wind, .player-meta .wind { width: 22px; height: 22px; display: inline-grid; place-items: center; color: #2b1912; background: #f0d27d; border: 1px solid #fff0b3; font: 900 14px var(--serif); }
.opponent-info em { color: #f0c768; font-style: normal; }
.opponent-info i { width: 5px; height: 5px; border-radius: 50%; background: #52655d; }
.opponent-info i.turn { background: #fff560; box-shadow: 0 0 10px #fff560; animation: blink .7s steps(2) infinite; }
@keyframes blink { 50% { opacity: .25; } }

.concealed-hand { display: flex; justify-content: center; gap: 1px; margin-top: 4px; }
.tile-back {
  width: 18px; height: 29px; display: block; border: 0;
  background: url("assets/tiles/back.png") center/100% 100% no-repeat;
  filter: drop-shadow(1px 2px 0 #062026); image-rendering: auto;
}
.seat-left .opponent-info, .seat-right .opponent-info { display: flex; }
.seat-left .concealed-hand, .seat-right .concealed-hand { position: absolute; top: 90px; display: flex; flex-direction: column; gap: 0; }
.seat-left .concealed-hand { left: 2px; }
.seat-right .concealed-hand { right: 2px; }
.seat-left .tile-back, .seat-right .tile-back { width: 18px; height: 29px; margin: -5px 5px; transform: rotate(90deg); }

.river { display: grid; grid-template-columns: repeat(6, 28px); gap: 2px; justify-content: center; }
.seat-top .river { margin-top: 5px; }
.seat-left .river { position: absolute; left: 40px; top: 66px; }
.seat-right .river { position: absolute; right: 40px; top: 66px; }
.river-tile {
  position: relative; width: 28px; height: 37px; display: grid; place-items: center;
  background: url("assets/tiles/front.png") center/100% 100% no-repeat;
  filter: drop-shadow(1px 2px 0 #243a2c); image-rendering: auto;
}
.river-tile img { width: 100%; height: 100%; display: block; object-fit: contain; pointer-events: none; user-select: none; image-rendering: auto; }
.river-tile.riichi-discard { transform: rotate(90deg); margin: 0 4px; }

.center-console {
  position: absolute; z-index: 6; left: 50%; top: 45%; width: 222px; min-height: 154px; transform: translate(-50%,-50%);
  display: grid; grid-template-columns: 70px 1fr 70px; grid-template-rows: 69px auto auto; gap: 3px; padding: 8px;
  color: #d8e7d8; background: linear-gradient(135deg, rgba(3,23,24,.95), rgba(6,39,37,.96)); border: 3px solid #b1813f;
  box-shadow: inset 0 0 0 2px #24180d, 4px 5px 0 rgba(0,0,0,.45);
}
.compass { position: relative; display: grid; grid-template-columns: 1fr 1fr; place-items: center; color: #608a7e; font: 700 11px var(--serif); }
.compass b { position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; transform: translate(-50%,-50%) rotate(45deg); display: grid; place-items: center; color: #20180d; background: var(--gold); border: 2px solid #fff0a1; font-size: 17px; }
.compass b::first-letter { transform: rotate(-45deg); }
.wall-counter { display: flex; align-items: baseline; justify-content: center; gap: 2px; border-left: 1px solid #345a51; border-right: 1px solid #345a51; }
.wall-counter strong { color: #fff4aa; font-size: 30px; text-shadow: 2px 2px #000; }
.wall-counter small { color: #84aaa0; font-size: 8px; writing-mode: vertical-rl; }
.dora-box { text-align: center; font-size: 8px; color: #80a59b; }
#dora-indicator { margin: 3px auto 0; }
#status-message { grid-column: 1 / -1; min-height: 25px; margin: 0; display: grid; place-items: center; color: #e9d59a; font-size: 10px; text-align: center; }
.action-buttons { grid-column: 1/-1; min-height: 31px; display: flex; gap: 5px; align-items: center; justify-content: center; }
.game-action {
  min-width: 58px; padding: 6px 9px; cursor: pointer; color: #2c160d; background: linear-gradient(#ffdc72, #be742d); border: 2px solid #fff0a1;
  box-shadow: 2px 3px 0 #3e1d13; font-weight: bold;
}
.game-action.red { color: #fff; background: linear-gradient(#d74a3d,#8e201e); border-color: #ff9b79; }
.game-action.blue { color: #fff; background: linear-gradient(#3a838e,#22505e); border-color: #79c4c0; }
.game-action:disabled { opacity: .35; cursor: default; filter: grayscale(1); }

.player-area { position: absolute; z-index: 8; left: 5%; right: 5%; bottom: 3px; height: 30%; }
.player-meta { display: flex; justify-content: center; align-items: center; height: 28px; }
.player-meta > div { display: flex; align-items: center; gap: 8px; padding: 3px 10px; background: rgba(2,18,18,.87); border: 1px solid #72917d; }
.player-meta b { color: #fff; font: 700 12px var(--serif); }
.player-meta em { color: #f1cd68; font-style: normal; font-size: 11px; }
.riichi-stick { margin-left: 9px; padding: 2px 18px; color: #bd2829; background: #f2e9d0; border: 1px solid #a6a08d; font: 900 10px var(--serif); }
.player-river { min-height: 39px; margin: 3px auto 3px; }
.player-hand {
  --hand-gap: 2px; --draw-gap: 8px;
  display: grid; grid-template-columns: repeat(13, var(--tile-w)) calc(var(--tile-w) + var(--draw-gap));
  align-items: end; justify-content: start; column-gap: var(--hand-gap); width: max-content; min-height: var(--tile-h); margin: 0 auto;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.player-hand.awaiting-draw::after {
  content: "ツモ"; grid-column: 14; width: var(--tile-w); height: var(--tile-h); margin-left: var(--draw-gap);
  display: grid; place-items: center; color: rgba(225,241,224,.28); border: 1px dashed rgba(225,241,224,.2); border-radius: 4px;
  font-size: 8px; writing-mode: vertical-rl; letter-spacing: .18em;
}
.player-hand.input-locked { pointer-events: none; }
.player-hand.input-locked .tile { cursor: default; }

.tile {
  position: relative; flex: 0 0 var(--tile-w); width: var(--tile-w); height: var(--tile-h); padding: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: url("assets/tiles/front.png") center/100% 100% no-repeat; border: 0;
  filter: drop-shadow(1px 4px 0 #1a4237) drop-shadow(1px 2px 0 rgba(0,0,0,.35));
  transition: transform .08s, filter .08s; image-rendering: auto;
}
.tile img { width: 100%; height: 100%; display: block; object-fit: contain; pointer-events: none; user-select: none; image-rendering: auto; backface-visibility: hidden; }
.player-hand .tile:hover, .player-hand .tile.keyboard-selected, .player-hand .tile.touch-selected {
  transform: translateY(-9px);
  filter: brightness(1.08) drop-shadow(0 4px 0 #15382f) drop-shadow(0 0 3px rgba(255,239,142,.45));
}
.player-hand .tile.guide-best { outline: 3px solid #ffe05a; outline-offset: -2px; filter: drop-shadow(0 0 5px rgba(255,224,90,.9)); }
.player-hand .tile.guide-good { outline: 2px solid #75d9d0; outline-offset: -2px; }
.player-hand .tile.guide-best::after {
  content: "推"; position: absolute; z-index: 3; right: -3px; top: -8px; width: 17px; height: 17px; display: grid; place-items: center;
  color: #27160a; background: #ffe05a; border: 1px solid #fff5ad; border-radius: 50%; box-shadow: 1px 2px 0 #69351d; font: 900 10px var(--serif);
}
.player-hand .tile.long-pressing::before {
  content: ""; position: absolute; z-index: 4; left: 3px; right: 3px; bottom: 3px; height: 4px;
  background: #ffe05a; border: 1px solid #fff5ad; box-shadow: 0 0 4px rgba(255,224,90,.9);
  transform: scaleX(0); transform-origin: left center; animation: long-press-fill .52s linear forwards; pointer-events: none;
}
.player-hand .tile.long-pressing { filter: brightness(1.12) drop-shadow(0 0 4px rgba(255,224,90,.8)); }
@keyframes long-press-fill { to { transform: scaleX(1); } }
.player-hand .tile:active { transform: translateY(-5px) scale(.98); }
.player-hand .tile.drawn { margin-left: var(--draw-gap); }
.player-hand .tile.riichi-option { animation: option-glow .75s steps(2) infinite; }
@keyframes option-glow { 50% { transform: translateY(-7px); filter: drop-shadow(0 0 4px #ffe15a) drop-shadow(0 0 2px #ffe15a); } }
.tile.small { --tile-w: 31px; cursor: default; }
.tile.tiny { --tile-w: 25px; cursor: default; }

.practice-panel {
  position: absolute; z-index: 12; left: 50%; bottom: calc(30% + 5px); width: min(520px, 58%); min-height: 44px; padding: 7px 12px;
  transform: translateX(-50%); text-align: center;
  color: #17312b; background: #f0df9b; border: 3px solid #7e4a25; box-shadow: inset 0 0 0 2px #fff1af, 3px 4px #08241f;
}
.practice-panel b { display: block; color: #8e281f; font: 900 12px var(--serif); }
.practice-panel p { margin: 4px 0 0; font-size: 9px; line-height: 1.5; }
.discard-guide-panel {
  position: absolute; z-index: 13; left: 50%; bottom: calc(30% + 5px); width: min(640px, 64%); min-height: 58px; padding: 8px 12px;
  transform: translateX(-50%); color: #e6f2e8; background: linear-gradient(135deg, rgba(6,31,35,.97), rgba(12,55,52,.97));
  border: 2px solid #e1b853; box-shadow: inset 0 0 0 2px #183f3d, 4px 5px 0 rgba(0,0,0,.45);
}
.guide-head { display: flex; align-items: baseline; justify-content: center; gap: 10px; flex-wrap: wrap; }
.guide-head b { color: #9bd8cc; font-size: 10px; }.guide-head b em { padding: 2px 5px; color: #1d2a23; background: #8ed3bc; font-style: normal; }
.guide-head strong { color: #ffe277; font: 900 17px var(--serif); text-shadow: 2px 2px #5c281b; }
.guide-head span { color: #b8d2ca; font-size: 9px; }
.discard-guide-panel p { margin: 4px 0 2px; color: #f1e3b8; font-size: 9px; line-height: 1.45; text-align: center; }
.discard-guide-panel small { display: block; color: #98b8b0; font-size: 8px; line-height: 1.45; text-align: center; }

.overlay { position: absolute; z-index: 40; inset: 48px 0 0; display: grid; place-items: center; background: rgba(1,8,10,.73); }
.result-card {
  width: min(520px, 92vw); padding: 20px; text-align: center; color: #f5eac9;
  background: linear-gradient(145deg, #173e42, #071b22); border: 4px double #d9a94f; box-shadow: 8px 10px 0 rgba(0,0,0,.55);
}
.result-card .callout { margin: -8px 0 4px; color: var(--gold); font: 900 clamp(34px, 7vw, 60px) var(--serif); text-shadow: 3px 3px #8e2923, 6px 6px #000; }
.result-hand { display: flex; justify-content: center; gap: 2px; margin: 12px 0; }
.yaku-line { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; }
.yaku-chip { padding: 4px 7px; color: #21322a; background: #f5df9b; border: 1px solid #a87e39; font: 700 11px var(--serif); }
.score-burst { margin: 11px 0; color: #ffe16d; font: 900 26px var(--serif); }
.result-card button { margin: 5px; padding: 8px 18px; cursor: pointer; color: #24150e; background: var(--gold); border: 2px solid #fff2aa; box-shadow: 3px 3px #5b2d1e; font-weight: bold; }
.ranking { width: 90%; margin: 12px auto; border-collapse: collapse; font-size: 13px; }
.ranking td { padding: 6px; border-bottom: 1px solid #41625d; }.ranking tr:first-child { color: #ffe36d; }

/* ---------- Learning dojo ---------- */
#learn-screen { overflow-y: auto; background: linear-gradient(rgba(4,20,24,.94),rgba(3,11,15,.97)), repeating-linear-gradient(90deg,#183d3b 0 2px,#102e31 2px 18px); }
.learn-header { min-height: 92px; display: grid; grid-template-columns: 150px 1fr 150px; align-items: center; padding: 10px 4%; background: #0b242b; border-bottom: 4px solid #a56a32; }
.learn-header > div:nth-child(2) { text-align: center; }
.learn-header small { color: #8eaaa4; letter-spacing: .3em; }
.learn-header h2 { margin: 0; color: var(--gold); font: 900 30px var(--serif); text-shadow: 2px 2px #000; }
.dojo-rank { justify-self: end; padding: 7px 10px; color: #b8d0c8; border: 1px solid #57756e; font-size: 11px; }.dojo-rank b { color: #ffe06a; font-size: 18px; }
.learn-tabs { position: sticky; top: 0; z-index: 5; display: flex; justify-content: center; gap: 3px; padding: 8px; background: rgba(4,15,19,.93); }
.learn-tabs button { min-width: 130px; padding: 8px 15px; cursor: pointer; color: #86aaa2; background: #102d32; border: 1px solid #416660; }
.learn-tabs button.active { color: #20150b; background: var(--gold); border-color: #fff1a1; }
.learn-content { width: min(920px, 94%); margin: 0 auto; padding: 18px 0 50px; }
.quiz-card { padding: clamp(14px,3vw,28px); background: rgba(11,42,44,.92); border: 3px double #9c7137; box-shadow: 7px 8px rgba(0,0,0,.35); }
.quiz-top { display: flex; align-items: center; justify-content: space-between; color: #87aaa3; font-size: 11px; }
.quiz-top b { color: var(--gold); }
.quiz-question { margin: 14px 0; color: #f5e6b5; font: 700 clamp(15px,2.4vw,21px) var(--serif); text-align: center; }
.quiz-hand { display: flex; justify-content: center; gap: 3px; min-height: 59px; margin: 14px 0 18px; }
.quiz-context { margin: 0 auto 12px; text-align: center; color: #8eb9b0; font-size: 11px; }
.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quiz-option { padding: 11px; cursor: pointer; color: #e5efe8; background: #123a40; border: 2px solid #3e706c; box-shadow: 3px 3px #041216; }
.quiz-option:hover { border-color: #e7c862; }.quiz-option.correct { color: #17301f; background: #7fd58d; border-color: #c9ffb7; }.quiz-option.wrong { background: #8b302d; border-color: #e87661; }
.quiz-feedback { margin-top: 14px; padding: 13px; color: #23302b; background: #f0e1b0; border-left: 7px solid #d49c3d; line-height: 1.65; font-size: 12px; }
.quiz-next { display: block; margin: 14px auto 0; padding: 9px 22px; cursor: pointer; color: #241408; background: var(--gold); border: 2px solid #fff2aa; box-shadow: 3px 3px #602c1b; }

.guide-intro { color: #9ab8b2; text-align: center; line-height: 1.7; }
.yaku-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.yaku-card { padding: 12px; background: #0e3035; border: 1px solid #4d7168; border-top: 4px solid #ca9b49; }
.yaku-card header { display: flex; justify-content: space-between; align-items: baseline; }.yaku-card h3 { margin: 0; color: #f5e5b4; font: 700 17px var(--serif); }.yaku-card strong { color: #ffcf55; }
.yaku-card p { margin: 7px 0 0; color: #9bb7b0; font-size: 11px; line-height: 1.55; }
.yaku-card.yakuman { border-top-color: #c43c36; background: #3a2021; }
.score-section { margin-bottom: 22px; padding: 15px; background: #0c2b31; border: 1px solid #4b6d66; }
.score-section h3 { margin: 0 0 10px; color: #ebcb75; font: 700 18px var(--serif); }
.score-table { width: 100%; border-collapse: collapse; text-align: center; color: #dbe7dd; font-size: 12px; }
.score-table th { color: #1a221d; background: #d6ba69; }.score-table th,.score-table td { padding: 7px 5px; border: 1px solid #41615b; }.score-table tr:nth-child(even) td { background: #12383a; }
.score-note { color: #8eaaa3; font-size: 11px; line-height: 1.6; }

/* ---------- Modal ---------- */
.modal { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(0,5,8,.8); }
.modal-card { position: relative; width: min(660px, 96vw); max-height: 90vh; overflow-y: auto; padding: 24px; color: #e4eee3; background: #0c2930; border: 4px double #c79645; box-shadow: 8px 9px #000; }
.modal-close { position: absolute; right: 8px; top: 7px; width: 31px; height: 31px; cursor: pointer; color: #fff; background: #782a27; border: 2px solid #d87257; }
.modal-card h2 { margin: 0 0 13px; color: var(--gold); font: 900 25px var(--serif); }.modal-card h3 { color: #e0c979; font: 700 15px var(--serif); }.modal-card p,.modal-card li { color: #a9c0ba; font-size: 12px; line-height: 1.65; }
.rules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }.rules-grid div { padding: 10px; border: 1px solid #42625c; background: #102f34; }.rules-grid b { color: #efd37f; }

@media (max-width: 760px) {
  :root { --tile-w: clamp(25px, 6.4vw, 39px); }
  .game-hud { height: 43px; grid-template-columns: 90px 1fr 170px; padding: 0 4px; }
  .round-plate span { font-size: 15px; }.round-plate small,.hud-center b { display: none; }.hud-center span { font-size: 9px; }
  .hud-actions { gap: 2px; }.hud-actions button { padding: 4px 3px; font-size: 7px; }
  .table { height: calc(100dvh - 43px); border-width: 5px; }
  .center-console { top: 43%; transform: translate(-50%,-50%) scale(.77); }
  .seat-top { left: 15%; right: 15%; }.opponent-info { font-size: 8px; }.opponent-info .wind { width: 18px;height:18px;font-size:11px; }
  .seat-left,.seat-right { width: 95px; top: 16%; bottom: 29%; }.seat-left .river { left: 24px; }.seat-right .river { right: 24px; }
  .river { grid-template-columns: repeat(6, 19px); gap: 1px; }.river-tile { width: 19px; height: 26px; font-size: 10px; }.seat-left .river,.seat-right .river { grid-template-columns: repeat(4, 19px); }
  .player-area { left: 1%; right: 1%; height: 31%; }.player-hand { --hand-gap: 0px; --draw-gap: 4px; }
  .tile { padding: 0; }.practice-panel,.discard-guide-panel { bottom: calc(31% + 3px); width: 68%; padding: 5px 7px; }.practice-panel p { font-size: 7px; }
  .guide-head { gap: 5px; }.guide-head strong { font-size: 13px; }.discard-guide-panel p { font-size: 7px; }.discard-guide-panel small { font-size: 7px; }
  .mode-grid { gap: 6px; }.mode-card { padding-left: 6px; gap: 6px; }.mode-icon { flex-basis: 34px; width:34px;height:34px;font-size:19px; }.mode-body b { font-size: 13px; }.mode-body small { font-size: 8px; }
  .learn-header { grid-template-columns: 90px 1fr 80px; }.learn-header h2 { font-size: 21px; }.dojo-rank { padding: 5px;font-size:8px; }.learn-tabs button { min-width: 0; flex: 1; padding:7px 3px;font-size:10px; }
  .quiz-options { grid-template-columns: 1fr; }.quiz-hand { gap: 1px; }.yaku-grid { grid-template-columns: 1fr 1fr; }.score-table { font-size: 9px; }
}

@media (max-height: 650px) {
  .title-frame { justify-content: flex-start; padding-top: 8px; }.title-emblem { top: 18px; }.title-copy { margin-bottom: 7px; }
  .mode-card { min-height: 55px; }.title-actions { margin-top: 6px; }.title-controls { margin-top: 4px; }
  .title-disclaimer { margin-top: 4px; padding: 4px 7px; font-size: 7px; line-height: 1.28; }
  .title-disclaimer b { margin-bottom: 1px; }
  .player-area { height: 31%; }.center-console { transform: translate(-50%,-50%) scale(.88); }
}

@media (max-width: 520px) {
  :root { --tile-w: clamp(19px, 6.25vw, 25px); }
  .series-label { margin-top: 3px; }.title-emblem { display: none; } h1 { height: 85px; } h1 span,h1 strong { font-size: 42px; }
  .title-copy { font-size: 10px; }.mode-grid { grid-template-columns: 1fr; width: 88%; }.mode-card { min-height: 51px; }.title-actions { position: absolute; right: 4px; top: 4px; flex-direction: column; gap: 3px; }.subtle-btn { padding: 4px 6px;font-size:8px; }.title-controls { display:none; }
  .title-disclaimer { width: 94%; font-size: 7px; line-height: 1.3; }
  .seat-left .opponent-info b,.seat-right .opponent-info b,.seat-left .opponent-info em,.seat-right .opponent-info em { display:none; }
  .practice-panel { display: none; }.discard-guide-panel { width: 94%; min-height: 48px; }.discard-guide-panel p { display: none; }.discard-guide-panel small { max-height: 25px; overflow: hidden; }
  .quiz-hand .tile { --tile-w: clamp(19px, 6vw, 25px); }.tile.tiny { --tile-w: 20px; }
  .yaku-grid { grid-template-columns: 1fr; }.rules-grid { grid-template-columns: 1fr; }
}
