:root {
  --line: #35515e;
  --ink: #dce7eb;
  --felt: #0d4d3d;
  --felt-2: #0a3f33;
  --panel: #132228;
  --accent: #d6b46a;
}
* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(circle at 50% 10%, #1a2b31 0%, #0d1418 55%, #090d10 100%); color: var(--ink); font-family: "BIZ UDPGothic", sans-serif; }
.hidden { display: none !important; }
.game-shell { min-height: 100vh; padding: 8px; }
.panel { margin: 10px auto 0; max-width: 980px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
#game-screen { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.game-topbar { height: 48px; width: min(96vw, 1280px); display: flex; align-items: center; }
.compact-status { width: 100%; margin: 0; display: flex; align-items: center; gap: 10px; }
.compact-badge, .badge { border-radius: 999px; padding: 3px 9px; background: #2b454f; color: #f0dca9; font-weight: 700; }
.status-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
label { display: grid; gap: 6px; }
input { border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: #0f1a20; color: var(--ink); }
.action-row { display: flex; flex-wrap: wrap; gap: 8px; }
.lobby-room-list { margin-top: 12px; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.room-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: #0f1a20; display: grid; gap: 8px; }
.room-head { display: flex; align-items: center; justify-content: space-between; }
.room-id { font-weight: 700; }
.room-status { color: #f0dca9; font-size: 0.92rem; }
.room-note { font-size: 0.9rem; color: #9ec0cb; min-height: 1.2em; }
.room-slots { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 0.95rem; }
.room-actions { display: flex; flex-wrap: wrap; gap: 6px; }
button { border: 1px solid var(--line); background: #1c2d34; color: var(--ink); border-radius: 8px; padding: 8px 10px; cursor: pointer; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.overlay-button { background: #21353d; border-color: #476474; }
.table-board { position: relative; width: min(96vw, 1280px); height: min(78vh, 760px); border-radius: 16px; background: linear-gradient(145deg, var(--felt) 0%, var(--felt-2) 100%); border: 2px solid #254639; box-shadow: inset 0 0 0 2px rgba(255,255,255,.04); overflow: hidden; }
.table-center { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 220px; height: 160px; border-radius: 12px; border: 1px solid #335d4f; background: rgba(7,20,18,.7); display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 6px; }
.tc-round { font-size: 1.25rem; font-weight: 700; }
.seat { position: absolute; min-width: 120px; }
.seat-panel { background: rgba(7,20,18,.65); border: 1px solid #335d4f; border-radius: 8px; padding: 4px 8px; display: flex; gap: 6px; align-items: center; }
.seat-top { top: 14px; left: 50%; transform: translateX(-50%); }
.seat-left { left: 14px; top: 50%; transform: translateY(-50%) rotate(-90deg); transform-origin: left top; }
.seat-right { right: 14px; top: 50%; transform: translateY(-50%) rotate(90deg); transform-origin: right top; }
.seat-self { bottom: 132px; left: 50%; transform: translateX(-50%); }
.riichi-badge { background: #b33; border-radius: 4px; padding: 1px 4px; font-size: .7rem; }
.river { position: absolute; }
.river-grid { display: grid; grid-template-columns: repeat(6, 24px); grid-auto-rows: 34px; gap: 2px; padding: 6px; border-radius: 8px; background: rgba(7,20,18,.48); }
.river-top { left: 50%; top: 120px; transform: translateX(-50%); }
.river-self { left: 50%; bottom: 206px; transform: translateX(-50%); }
.river-left { left: 165px; top: 50%; transform: translateY(-50%); }
.river-right { right: 165px; top: 50%; transform: translateY(-50%); }
.river-left .river-grid, .river-right .river-grid { grid-template-columns: repeat(3, 24px); }
.opponent-hand { position: absolute; }
.back-tile { width: 24px; height: 34px; border-radius: 3px; border: 1px solid #586f8f; background: linear-gradient(145deg,#394d62,#253548); }
.opponent-hand-top { top: 64px; left: 50%; transform: translateX(-50%); display: flex; gap: 2px; }
.opponent-hand-left { left: 80px; top: 50%; transform: translateY(-50%); display: grid; gap: 2px; }
.opponent-hand-right { right: 80px; top: 50%; transform: translateY(-50%); display: grid; gap: 2px; }
.self-hand-area { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); width: min(94%, 1080px); background: rgba(7,20,18,.75); border: 1px solid #335d4f; border-radius: 12px; padding: 8px; }
.action-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.action-hint { margin: 0 0 6px; color: #f0dca9; min-height: 1.3em; }
.hand-tiles { display: flex; flex-wrap: nowrap; gap: 3px; overflow-x: auto; align-items: flex-end; }
.tile-btn { width: 40px; height: 56px; padding: 0; border-radius: 4px; background: #fffef8; border: 1px solid #889; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.tile-btn img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile-btn.tile-drawn { margin-left: 8px; border-color: var(--accent); }
.tile-btn.not-riichi-candidate { opacity: 0.35; filter: grayscale(0.8); }
.tile-gap { width: 10px; flex-shrink: 0; }
.dt-wrap { width: 22px; height: 31px; }
.dt-wrap img { width: 22px; height: 31px; object-fit: contain; display: block; }
.rot-0 { transform: rotate(0deg); }
.rot-90 { transform: rotate(90deg); }
.rot-180 { transform: rotate(180deg); }
.rot-270 { transform: rotate(270deg); }
.result-compact { width: min(96vw, 1280px); margin-top: 0; }
.result-card { border: 1px dashed var(--line); border-radius: 10px; padding: 10px; }
.log-heading { margin: 10px 0 6px; }
#logs { margin: 0; padding-left: 18px; }
.warn { color: #ffb07f; }
@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .table-board { height: 74vh; }
  .table-center { width: 180px; height: 140px; }
  .seat-self { bottom: 126px; }
  .river-left { left: 120px; }
  .river-right { right: 120px; }
}
.dice-chance-panel {
  border: 1px solid #5f6f2f;
  background: linear-gradient(180deg, rgba(85, 101, 35, 0.35), rgba(19, 34, 40, 0.95));
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
}
.dice-chance-title {
  margin: 0;
  font-size: 1.25rem;
  color: #ffe38e;
}
.dice-chance-count,
.dice-chance-reasons {
  margin: 6px 0 0;
}
.dice-roll-list {
  margin: 10px 0 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
}
.dice-roll-item {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px;
  background: rgba(10, 16, 19, 0.45);
}
.dice-roll-item-double {
  border-color: #f7cb66;
  box-shadow: 0 0 0 1px rgba(247, 203, 102, 0.2) inset;
}
.dice-roll-images {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
}
.dice-face {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #102028;
  object-fit: contain;
}
.dice-roll-text {
  font-weight: 700;
}
.dice-roll-double {
  margin-top: 4px;
  color: #ffe38e;
  font-weight: 700;
}
.dice-chance-summary {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.25);
  display: grid;
  gap: 4px;
}
.dice-final {
  font-size: 1.02rem;
  font-weight: 700;
}
@media (max-width: 640px) {
  .dice-chance-title {
    font-size: 1.15rem;
  }
  .dice-face {
    width: 30px;
    height: 30px;
  }
}
