:root { --felt: #1f5c3a; --walnut: #4a2c18; --brass: #c9a55a; }
html, body { height: 100%; }
body { background: #0d0b09; }

.lobby-bg {
  position: absolute; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(201,165,90,.18), transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(31,92,58,.55), transparent 60%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.012) 0 2px, transparent 2px 9px),
    #0d0b09;
}
.card { position: relative; background: linear-gradient(180deg, rgba(36,28,20,.92), rgba(22,17,12,.95)); border: 1px solid rgba(201,165,90,.25); border-radius: 18px; padding: 22px; box-shadow: 0 30px 80px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.05); }
.card-dark { background: rgba(14,11,8,.9); border: 1px solid rgba(201,165,90,.25); border-radius: 14px; padding: 12px; backdrop-filter: blur(8px); }
.card-title { font-family: "Noto Serif TC", serif; font-weight: 700; font-size: 1.05rem; color: #e4c982; margin-bottom: 8px; display: flex; align-items: baseline; gap: 8px; }
.card-title .en { font-family: Inter, sans-serif; font-weight: 500; font-size: .75rem; color: rgba(243,238,226,.45); letter-spacing: .08em; text-transform: uppercase; }
.input { width: 100%; background: rgba(0,0,0,.35); border: 1px solid rgba(201,165,90,.25); color: #f3eee2; border-radius: 10px; padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: rgba(201,165,90,.7); box-shadow: 0 0 0 3px rgba(201,165,90,.15); }
.input-sm { padding: 6px 10px; font-size: .85rem; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: rgba(243,238,226,.75); }
.field i { font-style: normal; color: rgba(243,238,226,.4); margin-left: 4px; font-size: .7rem; }
.btn-primary { background: linear-gradient(180deg, #d6b56a, #b08a3c); color: #1b1208; font-weight: 700; border-radius: 12px; padding: 12px 18px; box-shadow: 0 8px 20px rgba(201,165,90,.25), inset 0 1px 0 rgba(255,255,255,.4); transition: transform .1s, filter .15s; }
.btn-primary:hover { filter: brightness(1.08); } .btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { filter: grayscale(.6) brightness(.7); cursor: not-allowed; }
.btn-secondary { background: rgba(201,165,90,.12); border: 1px solid rgba(201,165,90,.4); color: #e4c982; border-radius: 12px; padding: 10px 14px; font-weight: 600; transition: background .15s; }
.btn-secondary:hover { background: rgba(201,165,90,.22); }
.btn-ghost { color: rgba(243,238,226,.6); border-radius: 12px; padding: 10px 14px; } .btn-ghost:hover { color: #fff; background: rgba(255,255,255,.05); }

.room-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-radius: 12px; background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.06); cursor: pointer; transition: background .15s, border-color .15s; }
.room-item:hover { background: rgba(201,165,90,.08); border-color: rgba(201,165,90,.35); }

.seat-card { border-radius: 14px; padding: 14px; background: rgba(0,0,0,.3); border: 1px solid rgba(255,255,255,.08); min-height: 110px; display: flex; flex-direction: column; justify-content: space-between; }
.seat-card.you { border-color: rgba(201,165,90,.6); box-shadow: inset 0 0 0 1px rgba(201,165,90,.3); }
.seat-card.empty { border-style: dashed; color: rgba(243,238,226,.35); align-items: center; justify-content: center; }
.wind-badge { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 7px; background: #f3eee2; color: #1f2a44; font-family: "Noto Serif TC", serif; font-weight: 900; font-size: 15px; }

/* HUD */
.hud { z-index: 20; }
.hud-pill { display: inline-flex; align-items: center; gap: 6px; background: rgba(12,9,6,.72); border: 1px solid rgba(201,165,90,.3); border-radius: 999px; padding: 6px 14px; backdrop-filter: blur(6px); box-shadow: 0 6px 18px rgba(0,0,0,.4); }
.hud-pill .en { font-family: Inter, sans-serif; font-size: .7rem; color: rgba(243,238,226,.5); margin-left: 4px; }
.hud-btn { background: rgba(12,9,6,.72); border: 1px solid rgba(201,165,90,.3); color: #e4c982; border-radius: 10px; padding: 6px 12px; font-size: .8rem; font-weight: 600; backdrop-filter: blur(6px); }
.hud-btn:hover { background: rgba(201,165,90,.2); }

.panel { z-index: 15; min-width: 190px; background: rgba(12,9,6,.74); border: 1px solid rgba(201,165,90,.25); border-radius: 14px; padding: 10px 12px; backdrop-filter: blur(6px); box-shadow: 0 10px 30px rgba(0,0,0,.45); transition: border-color .2s, box-shadow .2s; }
.panel { display: flex; gap: 10px; align-items: flex-start; }
.panel .pbody { flex: 1; min-width: 0; }
.panel .cam { position: relative; width: 96px; height: 72px; border-radius: 8px; overflow: hidden; background: #0a0806; border: 1px solid rgba(201,165,90,.25); flex: none; }
.panel .cam video { width: 100%; height: 100%; object-fit: cover; display: block; background: #0a0806; }
.panel .cam.mirror video { transform: scaleX(-1); }
.panel .cam .cam-ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: .65rem; color: rgba(243,238,226,.45); text-align: center; padding: 4px; }
.panel .cam .cam-ctl { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 2px; justify-content: center; padding: 2px; background: linear-gradient(transparent, rgba(0,0,0,.6)); }
.panel .cam .cam-ctl button { font-size: .7rem; line-height: 1; padding: 3px 5px; border-radius: 5px; background: rgba(255,255,255,.12); color: #f3eee2; }
.panel .cam .cam-ctl button.off { background: rgba(192,39,45,.8); }
.panel.speaking .cam { border-color: #e4c982; box-shadow: 0 0 0 2px rgba(228,201,130,.55); }
.panel.active { border-color: rgba(228,201,130,.9); box-shadow: 0 0 0 2px rgba(201,165,90,.35), 0 10px 30px rgba(0,0,0,.5); }
.panel .flowers { display: flex; gap: 2px; margin-top: 6px; align-items: center; }
.panel .flowers .chip { width: 18px; height: 25px; border-radius: 3px; }
.panel .flowers .lbl { font-size: .68rem; color: rgba(243,238,226,.5); margin-right: 4px; }
.panel .river { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 8px; max-width: 8.5rem; }
#panel-2 .river { max-width: 26rem; }
#panel-2 { min-width: 0; }
.panel .river .chip { width: 20px; height: 27px; border-radius: 3px; }
.panel .river .chip.last { outline: 2px solid #e4c982; outline-offset: 1px; }
.panel .name { font-weight: 600; font-size: .95rem; display: flex; align-items: center; gap: 6px; }
.panel .score { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 1.05rem; }
.panel .score.pos { color: #8fd19e; } .panel .score.neg { color: #f28b82; }
.panel .meta { display: flex; gap: 6px; align-items: center; font-size: .72rem; color: rgba(243,238,226,.6); margin-top: 4px; }
.dealer-badge { background: #c0272d; color: #fff; font-family: "Noto Serif TC", serif; font-weight: 900; border-radius: 6px; padding: 0 6px; font-size: .75rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #8fd19e; display: inline-block; } .dot.off { background: #f28b82; }
.timer-bar { height: 3px; background: rgba(255,255,255,.08); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.timer-bar > div { height: 100%; background: linear-gradient(90deg, #e4c982, #c0272d); width: 100%; transition: width .25s linear; }
.bubble { position: absolute; left: 50%; top: -14px; transform: translate(-50%, -100%); background: #f3eee2; color: #1b1208; font-family: "Noto Serif TC", serif; font-weight: 900; font-size: 1.4rem; padding: 6px 16px; border-radius: 14px; box-shadow: 0 8px 22px rgba(0,0,0,.5); animation: pop .25s ease-out; white-space: nowrap; }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); border: 8px solid transparent; border-top-color: #f3eee2; border-bottom: 0; }
.bubble small { display: block; font-family: Inter, sans-serif; font-size: .65rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: rgba(27,18,8,.6); text-align: center; }
@keyframes pop { from { transform: translate(-50%, -80%) scale(.6); opacity: 0; } to { transform: translate(-50%, -100%) scale(1); opacity: 1; } }

.act { min-width: 84px; padding: 10px 18px; border-radius: 14px; font-family: "Noto Serif TC", serif; font-weight: 900; font-size: 1.35rem; line-height: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; border: 1px solid rgba(255,255,255,.15); box-shadow: 0 10px 25px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.3); transition: transform .1s, filter .15s; color: #1b1208; background: linear-gradient(180deg,#f7f1e1,#d9cdb0); }
.act small { font-family: Inter, sans-serif; font-weight: 600; font-size: .6rem; letter-spacing: .12em; text-transform: uppercase; opacity: .65; }
.act:hover { filter: brightness(1.06); transform: translateY(-2px); } .act:active { transform: translateY(0); }
.act.hu { background: linear-gradient(180deg,#e8484e,#b01f25); color: #fff; } .act.hu small { opacity: .8; }
.act.pass { background: rgba(20,16,12,.85); color: #e4c982; }
.act.kong, .act.pong, .act.chi { background: linear-gradient(180deg,#e4c982,#b8913f); }

.chip { display: inline-block; width: 30px; height: 41px; border-radius: 4px; background-size: cover; box-shadow: 0 1px 2px rgba(0,0,0,.5); vertical-align: middle; }
.chip.lg { width: 44px; height: 60px; border-radius: 6px; }
.chip.win { outline: 3px solid #e4c982; outline-offset: 2px; }
.chip.sm { width: 22px; height: 30px; border-radius: 3px; }
.chip-row { display: inline-flex; gap: 2px; margin-right: 10px; vertical-align: middle; }

.modal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.55); backdrop-filter: blur(4px); }
.modal-card { width: min(720px, 94vw); max-height: 88vh; overflow: auto; background: linear-gradient(180deg, rgba(40,31,22,.98), rgba(22,17,12,.98)); border: 1px solid rgba(201,165,90,.45); border-radius: 20px; padding: 26px; box-shadow: 0 40px 100px rgba(0,0,0,.7); animation: rise .3s ease-out; }
@keyframes rise { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.tai-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed rgba(201,165,90,.2); font-size: .95rem; }
.tai-row .en { color: rgba(243,238,226,.5); font-size: .8rem; margin-left: 8px; }

#chat-log .msg b { color: #e4c982; font-weight: 600; }
.hidden { display: none !important; }
canvas { display: block; }

/* settings */
.seg { display: flex; gap: 4px; background: rgba(0,0,0,.35); border: 1px solid rgba(201,165,90,.25); border-radius: 10px; padding: 3px; }
.seg button { flex: 1; font-size: .78rem; padding: 6px 4px; border-radius: 7px; color: rgba(243,238,226,.7); }
.seg button.on { background: rgba(201,165,90,.25); color: #e4c982; font-weight: 600; }
.act.en-only { font-family: Inter, "Noto Sans TC", sans-serif; font-size: 1.05rem; font-weight: 700; letter-spacing: .02em; padding-top: 14px; padding-bottom: 14px; }


/* ===================== mobile / compact mode ===================== */
#table-container canvas { touch-action: none; }
button, .act, .hud-btn, .room-item { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

#hand-strip { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: linear-gradient(180deg, rgba(12,9,6,.85), rgba(12,9,6,.97)); border-top: 1px solid rgba(201,165,90,.3); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); backdrop-filter: blur(8px); }
.hs-head { display: flex; align-items: center; gap: 8px; font-size: .8rem; padding: 0 2px 4px; flex-wrap: wrap; }
.hs-name { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.hs-score { font-family: ui-monospace, monospace; }
.hs-score.pos { color: #8fd19e; } .hs-score.neg { color: #f28b82; }
.hs-waits { display: inline-flex; align-items: center; gap: 2px; margin-left: auto; font-size: .7rem; color: #e4c982; }
.hs-head .timer-bar { flex-basis: 100%; margin-top: 2px; }
.hs-tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; }
.hs-tile { width: 40px; height: 55px; border-radius: 5px; background-size: cover; box-shadow: 0 2px 4px rgba(0,0,0,.6); border: 2px solid transparent; transition: transform .12s, border-color .12s; position: relative; flex: none; }
.hs-tile.drawn { margin-left: 10px; }
.hs-tile.lifted { transform: translateY(-10px); border-color: #e4c982; box-shadow: 0 8px 16px rgba(0,0,0,.7); }
.hs-tile.tenpai::after { content: ''; position: absolute; top: -3px; right: -3px; width: 9px; height: 9px; border-radius: 50%; background: #e4c982; box-shadow: 0 0 0 2px #0d0b09; }
.hs-tiles.disabled .hs-tile { opacity: .75; }
@media (max-width: 380px) { .hs-tile { width: 35px; height: 48px; } }

body.mobile #hand-strip { display: block; }
body.mobile #panel-0 { display: none; }
body.mobile #action-bar { bottom: calc(var(--strip-h, 120px) + 8px); width: 100%; padding: 0 8px; }
body.mobile .act { min-width: 64px; padding: 8px 12px; font-size: 1.15rem; }
body.mobile #turn-hint-wrap { font-size: .7rem; max-width: 95vw; }
body.mobile .hud-left { gap: 6px; left: 8px; top: 8px; }
body.mobile .hud-left .hud-pill { padding: 4px 9px; font-size: .72rem; }
body.mobile .hud-left .hud-pill .en { display: none; }
body.mobile #hud-round { font-size: .85rem; }
body.mobile .hud-code { display: none; }
body.mobile #btn-settings { top: 8px; right: 8px; }
#btn-menu { display: none; }
body.mobile #btn-menu { display: block; top: 8px; right: 52px; padding: 5px 10px; }
body.mobile .hud-right { display: none; flex-direction: column; align-items: stretch; top: 48px; right: 8px; gap: 6px; }
body.mobile .hud-right.open { display: flex; }
body.mobile .panel { min-width: 0; padding: 6px 8px; border-radius: 10px; }
body.mobile .panel .meta { font-size: .62rem; margin-top: 2px; }
body.mobile .panel .name { font-size: .78rem; gap: 4px; }
body.mobile .panel .score { font-size: .85rem; }
body.mobile .panel .cam { width: 64px; height: 48px; }
body.mobile .panel .cam .cam-ctl button { font-size: .6rem; padding: 2px 4px; }
body.mobile #panel-2 { top: 44px; max-width: 70vw; }
body.mobile #panel-3 { left: 6px; top: 110px; transform: none; max-width: 42vw; }
body.mobile #panel-1 { right: 6px; top: 110px; transform: none; max-width: 42vw; }
body.mobile #panel-1 .pbody .flex, body.mobile #panel-3 .pbody .flex { flex-direction: column; align-items: flex-start; gap: 0; }
body.mobile .bubble { font-size: 1rem; padding: 4px 10px; }
body.mobile #claim-status { top: auto; bottom: calc(var(--strip-h, 120px) + 64px); font-size: .72rem; max-width: 92vw; }
body.mobile #waits { display: none !important; }
body.mobile #chat { right: 0; left: 0; bottom: 0; width: auto; max-height: 60vh; border-radius: 16px 16px 0 0; z-index: 30; }
body.mobile .modal-card { padding: 16px; border-radius: 14px; max-height: 92vh; }
body.mobile .chip.lg { width: 34px; height: 46px; }
body.mobile .tai-row { font-size: .85rem; }

/* landscape phones: thinner strip, single row of tiles */
@media (max-height: 520px) {
  body.mobile .hs-tiles { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; padding-bottom: 2px; }
  body.mobile .hs-tile { width: 34px; height: 47px; }
  body.mobile #panel-2 { top: 6px; left: 50%; transform: translateX(-50%); max-width: 30vw; }
  body.mobile #panel-3, body.mobile #panel-1 { top: 56px; max-width: 30vw; }
  body.mobile .panel .meta { display: none; }
  body.mobile .hud-left .hud-pill { padding: 3px 8px; }
}

/* lobby / room on small screens */
@media (max-width: 640px) {
  #screen-lobby h1 { font-size: 3.5rem; }
  #screen-lobby header { margin-bottom: 1.25rem; }
  .card { padding: 16px; border-radius: 14px; }
  .input { font-size: 16px; } /* prevents iOS zoom on focus */
  #room-code { font-size: 2.25rem; }
  #screen-room .card > .flex:first-child .flex { width: 100%; }
}
