:root {
  color-scheme: dark;
  --ink: #e9eee7;
  --muted: #9da99f;
  --jade: #bad19a;
  --line: rgba(215, 226, 209, .12);
  font-family: "DM Sans", "Noto Sans TC", sans-serif;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 42% 31%, rgba(52, 94, 72, .16), transparent 49%),
    #111714;
}

button { font: inherit; cursor: pointer; }
.site-shell { width: min(1400px, calc(100% - 64px)); min-height: 100vh; margin: auto; }

.topbar { height: 78px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; font-size: 15px; font-weight: 700; letter-spacing: .08em; }
.brand-mark { width: 35px; height: 35px; display: grid; place-items: center; border: 1px solid #aebd8b; color: #d3daa1; font-family: "Noto Sans TC", sans-serif; font-size: 16px; }
.brand small { display: block; margin-top: 3px; color: #89968d; font-size: 8px; font-weight: 500; letter-spacing: .2em; }
.topbar-right { display: flex; align-items: center; gap: 22px; color: #aab4aa; font-size: 10px; }
.ai-status { display: flex; align-items: center; gap: 8px; }
.ai-status i { width: 7px; height: 7px; border-radius: 50%; background: #bad18a; box-shadow: 0 0 12px rgba(186, 209, 138, .6); }
.restart-button { padding: 8px 11px; border: 1px solid var(--line); background: rgba(29, 39, 33, .75); color: #ced7cb; font-size: 10px; }
.restart-button:hover { border-color: rgba(186, 209, 154, .5); color: #eef4df; }
.restart-button span { padding-left: 6px; color: var(--jade); font-size: 14px; }

.game-layout { padding: 21px 0 14px; }
.game-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 16px; }
.eyebrow { display: flex; align-items: center; gap: 9px; margin: 0 0 8px; color: #b6c798; font-size: 9px; font-weight: 700; letter-spacing: .18em; }
.eyebrow > span { width: 19px; height: 1px; background: var(--jade); }
.game-heading h1 { margin: 0; font-size: clamp(24px, 2.8vw, 35px); font-weight: 600; letter-spacing: .07em; }
.game-heading h1 em { color: var(--jade); font-style: normal; }
.heading-note { margin: 0 0 2px; color: #98a59b; font-size: 10px; line-height: 1.8; text-align: right; }

.table-layout { display: grid; grid-template-columns: minmax(0, 1fr) 248px; align-items: start; gap: 18px; }
.mahjong-table { min-width: 0; }
.table-felt {
  height: 660px;
  position: relative;
  overflow: hidden;
  border: 9px solid #503c2f;
  border-radius: 19px;
  background:
    radial-gradient(ellipse at center, rgba(119, 158, 109, .19), transparent 60%),
    radial-gradient(ellipse at center, #38694b 0, #28583e 60%, #204a36 100%);
  box-shadow: 0 18px 55px rgba(0,0,0,.32), inset 0 0 0 1px rgba(223, 201, 153, .24), inset 0 0 85px rgba(8, 24, 16, .26);
}
.table-felt::before { content: ""; position: absolute; inset: 12px; border: 1px solid rgba(222, 209, 168, .17); border-radius: 12px; pointer-events: none; }
.table-felt::after { content: ""; position: absolute; top: 50%; left: 50%; width: 360px; height: 360px; border: 1px solid rgba(228, 216, 177, .045); border-radius: 50%; transform: translate(-50%, -50%); pointer-events: none; }

.seat { position: absolute; z-index: 1; color: #e6ece2; }
.seat-heading, .player-heading { display: flex; align-items: center; gap: 7px; color: #cbd6c8; font-size: 9px; white-space: nowrap; }
.seat-wind { width: 21px; height: 21px; display: inline-grid; flex: 0 0 auto; place-items: center; border: 1px solid rgba(211, 218, 183, .28); border-radius: 50%; color: #ded8a5; font-family: "Noto Sans TC", sans-serif; font-size: 10px; }
.seat-name { font-weight: 600; }
.seat-score { color: #a9b5a8; font-variant-numeric: tabular-nums; }
.riichi-mark { padding: 2px 5px; background: #a3423a; color: #fff3e8; font-size: 8px; letter-spacing: .08em; }
.kita-count { color: #b6c69a; font-size: 8px; }
.seat-north { top: 16px; left: 50%; width: 360px; transform: translateX(-50%); }
.seat-north .seat-heading { justify-content: center; }
.opponent-hand { min-height: 29px; display: flex; align-items: center; justify-content: center; gap: 2px; margin: 6px auto; }
.tile-back { width: 15px; height: 23px; display: inline-block; flex: 0 0 auto; border: 1px solid #d6c9a7; border-radius: 2px; background: repeating-linear-gradient(45deg, #eee5ce 0, #eee5ce 2px, #d7ceba 2px, #d7ceba 3px); box-shadow: 0 1px 2px rgba(0,0,0,.22); }
.seat-north .discard-river { margin: 4px auto; }
.discard-river { width: max-content; max-width: 100%; display: grid; grid-template-columns: repeat(6, 25px); grid-auto-rows: 29px; gap: 2px; justify-content: center; }
.discard-tile { width: 24px; height: 28px; display: grid; place-items: center; border: 1px solid #c6c0ad; border-radius: 2px; background: #e8e2d1; box-shadow: 0 1px 2px rgba(0,0,0,.25); font-family: "Noto Sans TC", sans-serif; font-size: 10px; line-height: 1; }
.discard-tile.last-discard { outline: 2px solid #e08e70; outline-offset: 1px; }
.seat-west, .seat-east { top: 40%; width: 190px; }
.seat-west { left: 16px; }
.seat-east { right: 16px; }
.seat-west .seat-heading, .seat-east .seat-heading { justify-content: center; }
.seat-west .opponent-hand, .seat-east .opponent-hand { min-height: 24px; }
.seat-west .discard-river, .seat-east .discard-river { grid-template-columns: repeat(4, 25px); grid-auto-rows: 29px; }
.seat-east .discard-river { direction: rtl; }
.opponent-melds, .player-melds { min-height: 0; display: flex; justify-content: center; gap: 3px; }
.meld-group { display: flex; gap: 1px; padding: 2px; border: 1px solid rgba(224, 218, 192, .2); background: rgba(19, 37, 27, .33); }

.table-center { position: absolute; z-index: 1; top: 50%; left: 50%; width: 184px; padding: 13px 10px; border: 1px solid rgba(224, 218, 192, .17); background: rgba(25, 55, 39, .55); text-align: center; transform: translate(-50%, -54%); }
.round-label { display: flex; justify-content: center; gap: 6px; color: #d9e1d3; font-family: "Noto Sans TC", sans-serif; font-size: 13px; font-weight: 600; }
.round-label span:first-child { color: #e0d39d; }
.table-message { min-height: 27px; margin: 8px 0 4px; color: #c0cebd; font-size: 8px; line-height: 1.6; }
.wall-status { display: flex; justify-content: center; align-items: baseline; gap: 6px; color: #a6b6a4; font-size: 8px; }
.wall-status strong { color: #e1e9d8; font-size: 15px; font-variant-numeric: tabular-nums; }
.dora-area { display: flex; flex-direction: column; align-items: center; gap: 5px; margin-top: 10px; color: #a8b7a4; font-size: 7px; }
.dora-tiles { display: flex; gap: 3px; }
.table-decoration { position: absolute; top: 50%; z-index: 0; color: rgba(226, 215, 173, .1); font-family: "Noto Sans TC", sans-serif; font-size: 50px; transform: translateY(-50%); }
.decoration-left { left: 27%; }
.decoration-right { right: 27%; }

.seat-player { right: 15px; bottom: 13px; left: 15px; display: flex; flex-direction: column; align-items: center; }
.player-river { margin-bottom: 5px; }
.player-melds { margin-bottom: 5px; }
.player-heading { width: min(100%, 790px); margin: 0 auto 6px; }
.player-heading strong { color: #f0f2e7; font-size: 11px; }
.player-score { margin-left: auto; color: #d0dacd; font-size: 10px; font-variant-numeric: tabular-nums; }
.player-hand { width: min(100%, 810px); display: flex; align-items: flex-end; justify-content: flex-start; gap: 4px; overflow-x: auto; padding: 2px 3px 4px; scrollbar-color: #76816d transparent; scrollbar-width: thin; }
.tile {
  width: 43px;
  height: 64px;
  position: relative;
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 3px;
  border: 1px solid #d4d0c0;
  border-bottom: 4px solid #c4bca7;
  border-radius: 4px;
  background: linear-gradient(110deg, #f8f3e7, #e8e2d1);
  color: #292b28;
  box-shadow: 0 3px 4px rgba(9,18,12,.26);
  font-family: "Noto Sans TC", sans-serif;
  transition: transform .12s, box-shadow .12s;
}
button.tile:hover { z-index: 2; transform: translateY(-9px); box-shadow: 0 7px 12px rgba(8,16,10,.3); }
.tile.selected { border-color: #e7d796; box-shadow: 0 0 0 2px rgba(225, 209, 137, .7), 0 5px 13px rgba(0,0,0,.3); transform: translateY(-7px); }
.tile-rank { font-family: "DM Sans", "Noto Sans TC", sans-serif; font-size: 22px; font-weight: 600; line-height: 1.05; }
.tile-suit { margin-top: 1px; font-size: 14px; line-height: 1; }
.tile.honor .tile-rank { font-size: 25px; }
.tile.honor .tile-suit { display: none; }
.tile-man { color: #ba5548; }
.tile-pin { color: #3e6e9a; }
.tile-sou { color: #56804e; }
.tile-honor { color: #323933; }
.tile.red-five { box-shadow: inset 0 0 0 1px #ca7660, 0 3px 4px rgba(9,18,12,.26); }
.tile.red-five .tile-rank, .tile.red-five .tile-suit { color: #bc4f3d; }
.tile.red-mark::after { content: "赤"; position: absolute; top: 1px; right: 2px; color: #b54538; font-size: 6px; }
.tile-small { width: 24px; height: 28px; padding: 1px; border-bottom-width: 2px; border-radius: 2px; }
.tile-small .tile-rank { font-size: 11px; }
.tile-small .tile-suit { margin-top: 0; font-size: 7px; }
.tile-small.honor .tile-rank { font-size: 12px; }
.drawn-divider { display: none; }

.side-panel { display: flex; flex-direction: column; gap: 12px; }
.info-card { padding: 16px; border: 1px solid var(--line); background: linear-gradient(145deg, rgba(31, 42, 34, .94), rgba(22, 30, 25, .95)); box-shadow: 0 10px 30px rgba(0,0,0,.12); }
.turn-card .eyebrow { margin-bottom: 8px; color: #8d9d7b; font-size: 8px; }
.turn-card h2 { margin: 0; color: #e9eee3; font-size: 16px; font-weight: 600; letter-spacing: .03em; }
.turn-card > p { min-height: 35px; margin: 8px 0 13px; color: #9aa79b; font-size: 9px; line-height: 1.7; }
.action-buttons { display: flex; gap: 7px; }
.action-button, .next-button { min-width: 69px; padding: 8px 12px; border: 1px solid rgba(202, 217, 180, .24); background: #293a2d; color: #dfe8d6; font-size: 10px; font-weight: 600; }
.action-button:hover, .next-button:hover { border-color: var(--jade); background: #344a37; }
.win-button { border-color: rgba(209, 173, 120, .5); background: #594732; color: #f1dfb7; }
.riichi-button { border-color: rgba(191, 110, 93, .48); background: #512e2c; color: #f1d2c4; }
.kita-button { border-color: rgba(103, 158, 177, .45); background: #29444b; color: #d3e9e7; }
.call-panel { margin-top: 12px; padding: 10px; border: 1px solid rgba(213, 185, 122, .3); background: rgba(83, 68, 42, .25); }
.call-panel p { margin: 0 0 9px; color: #ead9ae; font-size: 9px; }
.call-buttons { display: flex; flex-wrap: wrap; gap: 5px; }
.call-button { padding: 6px 9px; border: 1px solid rgba(216, 206, 170, .24); background: rgba(46, 52, 39, .9); color: #e5e9d9; font-size: 9px; }
.call-button:hover { border-color: #d9cb9d; }
.call-button.ron-button { border-color: #cb8371; color: #ffd9ca; }
.round-result { margin-top: 13px; padding: 12px; border: 1px solid rgba(196, 209, 157, .28); background: rgba(45, 59, 38, .56); }
.round-result > p:first-child { margin: 0 0 5px; color: #e5dda9; font-size: 12px; font-weight: 700; }
.round-result > p:nth-child(2) { margin: 0 0 10px; color: #b5c0ae; font-size: 9px; line-height: 1.7; }
.next-button { width: 100%; display: flex; justify-content: space-between; }
.is-hidden { display: none !important; }

.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-title h3 { margin: 0; color: #dfe6dc; font-size: 11px; font-weight: 600; }
.hand-badge { padding: 4px 7px; background: rgba(185, 203, 151, .1); color: #bfce9d; font-size: 8px; }
.score-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; color: #aeb9ad; font-size: 9px; }
.score-row > span { display: flex; align-items: center; gap: 7px; }
.score-row strong { color: #e0e8dc; font-size: 10px; font-variant-numeric: tabular-nums; }
.score-row small { color: #758176; font-size: 8px; }
.score-dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; }
.dot-you { background: #cfbd7e; }
.dot-ai { background: #9db58d; }
.score-divider { height: 1px; margin: 7px 0; background: var(--line); }
.table-note { margin: 0; color: #859287; font-size: 8px; }
.guide-card { padding-bottom: 13px; }
.guide-icon { width: 17px; height: 17px; display: grid; place-items: center; border: 1px solid rgba(199, 215, 178, .3); border-radius: 50%; color: #becd9d; font-size: 9px; }
.guide-item { display: flex; align-items: center; gap: 9px; margin: 10px 0; }
.guide-tile { width: 26px; height: 32px; display: grid; place-items: center; border-radius: 3px; background: #e6e0cf; color: #b85447; font-family: "Noto Sans TC", sans-serif; font-size: 15px; }
.guide-tile.green-guide { color: #538052; }
.guide-tile.red-guide { color: #a7473c; }
.guide-item strong, .guide-item small { display: block; }
.guide-item strong { color: #d8e1d4; font-size: 9px; }
.guide-item small { margin-top: 4px; color: #929e92; font-size: 8px; }
.guide-footnote { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line); color: #879388; font-size: 8px; line-height: 1.7; }

.game-footer { min-height: 43px; display: flex; align-items: center; gap: 17px; color: #94a095; font-size: 8px; }
.game-footer > span { display: flex; align-items: center; gap: 5px; }
kbd { display: inline-grid; min-width: 25px; height: 19px; padding: 0 5px; place-items: center; border: 1px solid rgba(211, 223, 204, .25); border-radius: 3px; color: #d3ddce; font-family: inherit; font-size: 8px; }
.game-footer .footer-note { margin-left: auto; color: #758176; }

@media (max-width: 1050px) {
  .site-shell { width: calc(100% - 36px); }
  .table-layout { grid-template-columns: minmax(0, 1fr) 215px; gap: 11px; }
  .table-felt { height: 625px; }
  .side-panel .info-card { padding: 13px; }
  .seat-west, .seat-east { width: 155px; }
  .player-hand { gap: 3px; }
  .player-hand .tile { width: 39px; height: 60px; }
  .player-hand .tile-rank { font-size: 19px; }
  .player-hand .tile.honor .tile-rank { font-size: 22px; }
}

@media (max-width: 760px) {
  .site-shell { width: calc(100% - 24px); }
  .topbar { height: 65px; }
  .topbar-right { gap: 9px; font-size: 9px; }
  .brand { gap: 9px; font-size: 12px; }
  .brand-mark { width: 29px; height: 29px; font-size: 13px; }
  .brand small { font-size: 7px; }
  .restart-button { padding: 7px; font-size: 9px; }
  .game-layout { padding-top: 16px; }
  .game-heading { margin-bottom: 12px; }
  .game-heading h1 { font-size: clamp(21px, 4vw, 29px); }
  .heading-note { display: none; }
  .table-layout { grid-template-columns: 1fr; gap: 10px; }
  .table-felt { height: 680px; border-width: 6px; border-radius: 13px; }
  .seat-north { top: 10px; width: 290px; }
  .seat-west, .seat-east { top: 35%; width: 120px; }
  .seat-west { left: 5px; }
  .seat-east { right: 5px; }
  .seat-west .seat-heading, .seat-east .seat-heading { gap: 4px; font-size: 8px; }
  .seat-west .seat-score, .seat-east .seat-score { display: none; }
  .seat-west .opponent-hand, .seat-east .opponent-hand { gap: 1px; }
  .seat-west .tile-back, .seat-east .tile-back { width: 9px; height: 16px; }
  .seat-west .discard-river, .seat-east .discard-river { grid-template-columns: repeat(4, 18px); grid-auto-rows: 22px; }
  .seat-west .discard-tile, .seat-east .discard-tile { width: 17px; height: 21px; font-size: 8px; }
  .table-center { top: 48%; width: 144px; padding: 8px; }
  .table-message { font-size: 7px; }
  .seat-player { right: 4px; bottom: 8px; left: 4px; }
  .seat-player .discard-river { grid-template-columns: repeat(6, 19px); grid-auto-rows: 22px; }
  .seat-player .discard-tile { width: 18px; height: 21px; font-size: 8px; }
  .player-heading { width: calc(100% - 8px); }
  .player-hand { justify-content: flex-start; gap: 2px; width: 100%; padding: 2px 2px 7px; }
  .tile { width: 37px; height: 56px; }
  .tile-rank { font-size: 19px; }
  .tile-suit { font-size: 12px; }
  .tile.honor .tile-rank { font-size: 22px; }
  .tile-small { width: 22px; height: 26px; }
  .side-panel { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .turn-card { grid-column: 1 / -1; }
  .side-panel .info-card { padding: 12px; }
  .turn-card > p { min-height: auto; }
  .game-footer { flex-wrap: wrap; gap: 8px 13px; padding: 10px 0; }
  .game-footer .footer-note { width: 100%; margin-left: 0; }
}

@media (max-width: 420px) {
  .site-shell { width: calc(100% - 18px); }
  .topbar-right { gap: 6px; }
  .ai-status { gap: 5px; font-size: 8px; }
  .restart-button { font-size: 8px; }
  .game-heading h1 { font-size: 20px; }
  .table-felt { height: 650px; }
  .seat-west, .seat-east { width: 103px; }
  .seat-west .discard-river, .seat-east .discard-river { grid-template-columns: repeat(4, 16px); }
  .seat-west .discard-tile, .seat-east .discard-tile { width: 15px; }
  .seat-west .seat-name, .seat-east .seat-name { font-size: 8px; }
  .table-center { width: 129px; }
  .table-message { min-height: 25px; }
  .player-hand { gap: 1px; }
  .tile { width: 34px; height: 52px; }
  .tile-rank { font-size: 17px; }
  .tile-suit { font-size: 11px; }
  .tile.honor .tile-rank { font-size: 20px; }
}
