* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d1512; color: #f2efe6;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 10px; padding: 10px 18px; color: #fff; background: #3a4a44; }
button:hover { filter: brightness(1.15); }
button.primary { background: linear-gradient(#e0a12e, #c47a12); color: #1b1203; font-weight: 700; font-size: 17px; padding: 13px 22px; width: 100%; }
button:disabled { opacity: .45; cursor: default; filter: none; }

.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(6, 12, 10, .72); backdrop-filter: blur(4px); z-index: 20; overflow: auto; }
.card { width: min(430px, 100%); background: #17241f; border: 1px solid #2f4a40; border-radius: 16px; padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.55); max-height: 100%; overflow: auto; }
.card.wide { width: min(760px, 100%); }
.card h1 { margin: 0 0 4px; font-size: 26px; } .card h2 { margin: 0 0 12px; }
.sub { color: #9db3a9; margin: 4px 0 16px; font-size: 14px; }
.error { color: #ff8d7a; min-height: 1em; margin: 10px 0 0; font-size: 14px; }
input, select { width: 100%; font: inherit; padding: 12px; border-radius: 10px; border: 1px solid #3a5a4e; background: #0f1a16; color: #fff; margin-bottom: 12px; }
.row label { display: block; font-size: 13px; color: #9db3a9; margin: 12px 0 6px; }
#seats { display: grid; gap: 8px; margin: 14px 0; }
.seat { display: flex; align-items: center; gap: 10px; background: #0f1a16; border-radius: 10px; padding: 10px 12px; border: 1px solid #263b33; }
.seat .dot { width: 10px; height: 10px; border-radius: 50%; background: #56d17e; }
.seat.empty { color: #7c9087; } .seat.empty .dot { background: #4b5d55; }
.seat .tag { margin-left: auto; font-size: 12px; color: #e0a12e; }
#tables { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 14px; }
#tables button { text-align: left; background: #0f1a16; border: 1px solid #263b33; padding: 9px 11px; font-size: 13px; color: #9db3a9; }
#tables button b { display: block; color: #f2efe6; font-size: 15px; }
#tables button[aria-checked="true"] { border-color: #e0a12e; box-shadow: 0 0 0 1px #e0a12e; }
#tables button.busy b::after { content: ' · bermain'; color: #ff8d7a; font-weight: 500; font-size: 12px; }
#btn-leave { width: 100%; background: transparent; border: 1px solid #3a5a4e; color: #9db3a9; margin-top: 4px; }
#addr { background: #0f1a16; border: 1px dashed #3a5a4e; border-radius: 10px; padding: 10px 12px; font-size: 13px; color: #9db3a9; margin: 4px 0 14px; }
#addr b { color: #ffd98a; font-size: 15px; -webkit-user-select: text; user-select: text; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud > * { pointer-events: auto; }
#info { position: absolute; left: 10px; top: 10px; background: rgba(10,18,15,.78); border: 1px solid #2f4a40; border-radius: 12px; padding: 8px 12px; }
#roundname { font-weight: 800; font-size: 17px; color: #ffd98a; }
#roundsub { font-size: 12px; color: #b9cbc3; margin: 2px 0 6px; }
.doralabel { font-size: 11px; color: #9db3a9; text-transform: uppercase; letter-spacing: .05em; }
#dora { display: flex; gap: 3px; margin-top: 3px; }
#info.nodora .doralabel, #info.nodora #dora { display: none; }
img.t { height: 44px; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.5); vertical-align: middle; }
img.t.sm { height: 34px; } img.t.back { filter: brightness(.9); }
#topright { position: absolute; right: 10px; top: 10px; display: flex; gap: 6px; }
#topright button { background: rgba(10,18,15,.78); border: 1px solid #2f4a40; padding: 8px 12px; font-size: 14px; }
#topright button.off { opacity: .45; }
#topright button.unread { border-color: #ffd04a; box-shadow: 0 0 10px rgba(255,208,74,.6); }
#chat { position: absolute; left: 10px; top: calc(46% + 26px); width: 240px; display: none; background: rgba(10,18,15,.82); border: 1px solid #2f4a40; border-radius: 10px; padding: 6px; }
#chat.open { display: block; }
#chat-log { max-height: 110px; overflow-y: auto; font-size: 12.5px; line-height: 1.35; color: #dbe6e1; overflow-wrap: anywhere; -webkit-user-select: text; user-select: text; }
#chat-log:empty::before { content: 'Belum ada pesan.'; color: #7c9087; }
#chat-log b { color: #ffd98a; font-weight: 600; }
#chat-input { margin: 5px 0 0; padding: 6px 8px; font-size: 13px; border-radius: 7px; }

.plabel { position: absolute; background: rgba(10,18,15,.78); border: 1px solid #2f4a40; border-radius: 10px; padding: 5px 10px; font-size: 13px;
  white-space: nowrap; pointer-events: none !important; transition: box-shadow .2s, border-color .2s; }
.plabel b { color: #ffd98a; margin-right: 6px; } .plabel .pts { color: #b9cbc3; margin-left: 6px; font-variant-numeric: tabular-nums; }
.plabel .rc { color: #ff7a6b; font-weight: 700; margin-left: 6px; }
.plabel.turn { border-color: #ffd04a; box-shadow: 0 0 14px rgba(255,208,74,.65); }
.plabel.off { opacity: .6; }
#pl0 { left: 10px; bottom: calc(var(--hand-h, 110px) + 12px); }
#pl1 { right: 10px; top: 46%; transform: translateY(-50%); }
#pl2 { left: 268px; top: 10px; }
#pl3 { left: 10px; top: 46%; transform: translateY(-50%); }

#banners { position: absolute; inset: 0; pointer-events: none !important; }
.banner { position: absolute; transform: translate(-50%, -50%) scale(.6); font-weight: 900; font-size: clamp(30px, 6vw, 60px); letter-spacing: .04em;
  color: #fff; text-shadow: 0 0 18px #ff7a1a, 0 3px 0 #a33a00, 0 6px 14px rgba(0,0,0,.6); animation: pop 1.5s ease-out forwards; }
.banner.win { text-shadow: 0 0 22px #ffd04a, 0 3px 0 #9a6a00, 0 6px 14px rgba(0,0,0,.6); color: #fff6c9; }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%,-50%) scale(.4);} 12% { opacity: 1; transform: translate(-50%,-50%) scale(1.15);} 22% { transform: translate(-50%,-50%) scale(1);} 80% { opacity: 1;} 100% { opacity: 0; transform: translate(-50%,-60%) scale(1);} }

#bottom { position: absolute; left: 0; right: 0; bottom: calc(var(--hand-h, 110px) + 8px); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none !important; }
#bottom > * { pointer-events: auto; }
#hint { background: rgba(10,18,15,.82); border-radius: 999px; padding: 5px 14px; font-size: 13px; color: #d7e4de; display: flex; align-items: center; gap: 6px; }
#hint:empty { display: none; }
#hint .warn { color: #ff8d7a; font-weight: 700; } #hint .go { color: #ffd98a; font-weight: 700; }
#actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; padding: 0 10px; }
#actions:empty { display: none; }
#actions .lbl { background: rgba(10,18,15,.82); border-radius: 10px; padding: 6px 10px; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.act { font-weight: 800; font-size: clamp(16px, 2.6vw, 22px); padding: 12px 24px; border-radius: 14px; min-width: 96px; color: #fff;
  box-shadow: 0 4px 0 rgba(0,0,0,.35), 0 8px 18px rgba(0,0,0,.4); border: 2px solid rgba(255,255,255,.25); }
.act:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.35); }
.act.win { background: linear-gradient(#ffcf3e, #e08a00); color: #2a1700; animation: pulse 1s infinite; }
.act.riichi { background: linear-gradient(#ff6a5c, #c8241a); }
.act.pon { background: linear-gradient(#4aa3ff, #1c62c4); }
.act.chi { background: linear-gradient(#4fd08a, #1b8a4d); }
.act.kan { background: linear-gradient(#b987ff, #6b35c9); }
.act.pass { background: linear-gradient(#6b7a74, #48544f); }
.act.opt { display: flex; gap: 3px; padding: 8px 12px; background: #24362f; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(255,207,62,.35), 0 4px 0 rgba(0,0,0,.35); } }

.res-title { font-size: 24px; font-weight: 800; color: #ffd98a; margin: 0 0 4px; }
.res-tiles { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin: 10px 0; }
.res-tiles .gap { width: 12px; } .res-tiles .wintile { outline: 3px solid #ffcf3e; border-radius: 5px; }
.yaku { display: grid; grid-template-columns: 1fr auto; gap: 3px 18px; background: #0f1a16; border-radius: 10px; padding: 10px 14px; margin: 8px 0; font-size: 15px; }
.yaku .h { color: #ffd98a; font-weight: 700; text-align: right; }
.total { font-size: 19px; font-weight: 800; margin: 8px 0; } .total small { color: #9db3a9; font-weight: 500; }
.scores { display: grid; gap: 4px; margin: 12px 0; }
.scores .r { display: grid; grid-template-columns: 30px 1fr auto 80px; gap: 8px; align-items: center; background: #0f1a16; border-radius: 8px; padding: 7px 12px; font-variant-numeric: tabular-nums; }
.scores .plus { color: #6fe39a; text-align: right; } .scores .minus { color: #ff8d7a; text-align: right; } .scores .zero { color: #7c9087; text-align: right; }
.scores .me { outline: 1px solid #e0a12e; }
.win-block { border-top: 1px solid #2f4a40; padding-top: 12px; margin-top: 12px; } .win-block:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.dorarow { display: flex; gap: 14px; align-items: center; font-size: 12px; color: #9db3a9; flex-wrap: wrap; }
.helpbody { font-size: 14.5px; line-height: 1.5; color: #dbe6e1; } .helpbody ul { padding-left: 20px; margin: 6px 0; }
#toast { position: fixed; left: 50%; top: 64px; transform: translateX(-50%); background: #7a2a22; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 40; font-size: 14px; }
@media (max-width: 900px), (max-height: 500px) {
  img.t { height: 34px; } img.t.sm { height: 26px; }
  #info { padding: 6px 8px; } #roundname { font-size: 14px; } #roundsub { font-size: 10px; margin-bottom: 3px; } .doralabel { display: none; }
  .plabel { font-size: 11px; padding: 3px 7px; } #pl2 { left: auto; right: 10px; top: 52px; }
  #topright button { padding: 6px 8px; font-size: 12px; }
  .act { padding: 10px 14px; min-width: 70px; }
}
@media (max-aspect-ratio: 1/1) { /* portrait: label jangan menimpa petunjuk, tombol, atau buangan */
  #pl0 { bottom: calc(var(--hand-h, 110px) + 104px); }
  #pl2 { top: 92px; left: 50%; }
  #pl1, #pl3 { top: 124px; transform: none; }
  #chat { top: 154px; width: min(240px, 60vw); }
}
