/* å°ç£éº»å°‡ v19 â€” ç‰Œç‰†æŒ‡ç¤ºå™¨ + ä½ˆå±€ä¿®æ­£ */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root { --vh: 1vh; }
html, body { background: #1a5c2a; color: #fff; font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif; overflow: hidden; height: 100vh; height: calc(var(--vh, 1vh) * 100); width: 100vw; user-select: none; -webkit-user-select: none; touch-action: pan-x pan-y; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
#game-table { position: relative; width: 100%; height: 100%; }

/* ===== Tile base ===== */
.tile { display: inline-flex; align-items: center; justify-content: center; flex-direction: column; width: 32px; height: 44px; background: linear-gradient(135deg, #fff 0%, #e8e8e8 100%); border: 1px solid #999; border-radius: 4px; font-size: 22px; cursor: default; margin: 0.5px; box-shadow: 1px 2px 3px rgba(0,0,0,0.3); transition: transform 0.15s, box-shadow 0.15s; position: relative; flex-shrink: 0; }
.tile.back { background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); font-size: 0; border-color: #1e40af; }
.tile-top, .tile-bottom, .tile-single { display: block; text-align: center; line-height: 1.1; font-weight: bold; }
.tile-top { font-size: 0.7em; }
.tile-bottom { font-size: 0.55em; margin-top: -1px; }
.tile-single { font-size: 0.85em; }
.tc-black { color: #1a1a1a; } .tc-red { color: #dc2626; } .tc-green { color: #16a34a; }
.tc-blue { color: #2563eb; } .tc-gray { color: #9ca3af; }
.tc-flower-season { color: #d97706; } .tc-flower-plant { color: #7c3aed; }
.flower-tile { width: 22px !important; height: 30px !important; font-size: 16px !important; background: linear-gradient(135deg, #fef3c7, #fde68a) !important; border-color: #d97706 !important; }

/* ===== #field (green border) ===== */
#field { position: absolute; top: 55px; bottom: 75px; left: 55px; right: 55px; background: #166534; border: 3px solid rgba(255,215,0,0.3); border-radius: 6px; overflow: hidden; }

/* ===== Center info ===== */
#center-info { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: rgba(0,0,0,0.6); border-radius: 10px; padding: 8px 16px; text-align: center; font-size: 12px; z-index: 10; pointer-events: none; }
#center-info .wind-circle { font-size: 18px; font-weight: bold; color: #ffd700; text-shadow: 0 0 6px rgba(255,215,0,0.4); }
#center-info .round-detail { font-size: 11px; color: #ccc; margin-top: 1px; }
#center-info .remaining { color: #ffd700; margin-top: 2px; font-size: 11px; }
#version-tag { position: absolute; bottom: 2px; right: 4px; font-size: 9px; color: rgba(255,255,255,0.3); pointer-events: none; z-index: 1; }

/* ===== Wall (0~22px from edges) ===== */
.wall-side { position: absolute; z-index: 5; display: flex; gap: 0; align-items: center; justify-content: center; }
.wall-stack { display: flex; flex-direction: column; gap: 0; position: relative; flex-shrink: 0; margin: 0 0.5px; }
.wall-tile { width: 14px; height: 10px; background: linear-gradient(135deg, #3b82f6, #2563eb); border: 1px solid #1e40af; border-radius: 1px; box-shadow: 0 1px 1px rgba(0,0,0,0.3); }
.wall-upper { border-bottom: none; border-radius: 1px 1px 0 0; }
.wall-lower { border-radius: 0 0 1px 1px; }
.wall-draw .wall-tile { background: linear-gradient(135deg, #3b82f6, #2563eb); border-color: #1e40af; }
.wall-dead .wall-tile { background: linear-gradient(135deg, #ef4444, #dc2626); border-color: #991b1b; }
.wall-label { font-size: 8px; white-space: nowrap; padding: 0 2px; flex-shrink: 0; }
.wall-label-draw { color: #60a5fa; }
.wall-label-dead { color: #f87171; }

/* Next-draw indicator: ä¸‹ä¸€å¼µè¦æŠ“çš„ç‰Œ â€” é‡‘è‰²é–ƒçˆ */
.wall-next-draw .wall-tile { border-color: #fbbf24 !important; box-shadow: 0 0 4px rgba(251,191,36,0.8); }
.wall-next-draw { animation: nextDrawPulse 1s infinite alternate; }
@keyframes nextDrawPulse { from { opacity: 1; } to { opacity: 0.7; } }

/* Next-dead indicator: ä¸‹ä¸€å¼µè¦è£œçš„ç‰Œ â€” ç™½è‰²é–ƒçˆ */
.wall-next-dead .wall-tile { border-color: #fff !important; box-shadow: 0 0 4px rgba(255,255,255,0.8); }
.wall-next-dead { animation: nextDeadPulse 1s infinite alternate; }
@keyframes nextDeadPulse { from { opacity: 1; } to { opacity: 0.7; } }

.wall-h { flex-direction: row; }
#wall-north { top: 0; left: 50%; transform: translateX(-50%); padding: 3px 0; }
#wall-south { bottom: 0; left: 50%; transform: translateX(-50%); padding: 3px 0; }
.wall-v { flex-direction: column; }
#wall-west { left: 0; top: 50%; transform: translateY(-50%); padding: 0 3px; }
#wall-east { right: 0; top: 50%; transform: translateY(-50%); padding: 0 3px; }
.wall-v .wall-stack { flex-direction: row; margin: 0.5px 0; }
.wall-v .wall-tile { width: 10px; height: 14px; }
.wall-v .wall-upper { border-bottom: 1px solid #1e40af; border-right: none; border-radius: 1px 0 0 1px; }
.wall-v .wall-lower { border-radius: 0 1px 1px 0; }

/* ===== Discard river (50px from edges, inside #field) ===== */
.discard-area { position: absolute; z-index: 6; display: flex; gap: 1px; pointer-events: none; overflow: hidden; }
.discard-area > * { pointer-events: auto; }
.discard-row { display: flex; gap: 1px; flex-shrink: 0; }
.tile.discard-tile { width: 24px; height: 33px; font-size: 15px; cursor: default; flex-shrink: 0; margin: 0; }
#discard-south { bottom: 50px; left: 50%; transform: translateX(-50%); flex-direction: column-reverse; max-height: calc(50% - 60px); }
#discard-south .discard-row { flex-direction: row; justify-content: flex-start; min-width: 150px; }
#discard-north { top: 50px; left: 50%; transform: translateX(-50%); flex-direction: column; max-height: calc(50% - 60px); }
#discard-north .discard-row { flex-direction: row; justify-content: flex-start; min-width: 150px; }
#discard-west { left: 50px; top: 50%; transform: translateY(-50%); flex-direction: row; max-width: calc(50% - 60px); }
#discard-west .discard-row { flex-direction: column; min-height: 105px; }
#discard-east { right: 50px; top: 50%; transform: translateY(-50%); flex-direction: row-reverse; max-width: calc(50% - 60px); }
#discard-east .discard-row { flex-direction: column; min-height: 105px; }

/* ===== Melds (22~50px from edges) ===== */
.melds-area { position: absolute; z-index: 7; display: flex; gap: 2px; align-items: center; }
#melds-south { bottom: 22px; right: 50px; flex-direction: row-reverse; max-height: 28px; }
#melds-north { top: 22px; left: 50px; flex-direction: row; max-height: 28px; }
#melds-west { left: 22px; bottom: 50px; flex-direction: column-reverse; max-width: 28px; }
#melds-east { right: 22px; top: 50px; flex-direction: column; max-width: 28px; }
.melds-area .meld-group { display: flex; gap: 0; border: 1px solid rgba(255,255,255,0.2); border-radius: 3px; padding: 1px; background: rgba(0,0,0,0.3); }
.melds-area .tile.meld-tile { width: 20px; height: 28px; font-size: 14px; }

/* ===== Last discard highlight ===== */
.tile.last-discard { border: 2px solid #fbbf24 !important; box-shadow: 0 0 12px rgba(251,191,36,0.8), 0 0 24px rgba(251,191,36,0.4); animation: lastDiscardPulse 0.8s infinite alternate; transform: scale(1.15); z-index: 9; position: relative; }
@keyframes lastDiscardPulse { from { box-shadow: 0 0 8px rgba(251,191,36,0.6); } to { box-shadow: 0 0 16px rgba(251,191,36,1), 0 0 32px rgba(251,191,36,0.6); } }

/* ===== Players (OUTSIDE #field) ===== */
#player-south { position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 3px; z-index: 20; max-width: 100%; padding: 0 4px; }
#player-south .hand-area { display: flex; align-items: flex-end; justify-content: center; flex-wrap: nowrap; overflow: hidden; max-width: 100vw; padding-top: 18px; }
#player-south .info-row { display: flex; gap: 8px; align-items: center; font-size: 11px; }
.tile.hand-tile { cursor: pointer; width: 34px; height: 48px; font-size: 24px; flex-shrink: 1; min-width: 24px; }
.tile.hand-tile:hover { transform: translateY(-6px); box-shadow: 2px 4px 8px rgba(0,0,0,0.5); }
.tile.hand-tile.selected { transform: translateY(-12px); box-shadow: 0 0 12px rgba(255,215,0,0.8); border-color: #ffd700; }
.tile.hand-tile.just-drawn { margin-left: 10px; }
#player-north { position: absolute; top: 2px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: row; align-items: center; gap: 4px; z-index: 20; }
#player-west { position: absolute; left: 2px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; align-items: center; gap: 2px; z-index: 20; }
#player-east { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; align-items: center; gap: 2px; z-index: 20; }
.player-label { background: rgba(0,0,0,0.6); padding: 2px 8px; border-radius: 8px; font-size: 11px; white-space: nowrap; }
.player-label.is-dealer { border: 1px solid #ff6b6b; color: #ff6b6b; }
.wind-badge { display: inline-block; background: rgba(255,215,0,0.2); border: 1px solid #ffd700; color: #ffd700; font-size: 11px; font-weight: bold; padding: 0 5px; border-radius: 3px; margin-left: 3px; vertical-align: middle; }
.wind-badge.is-dealer { background: rgba(255,107,107,0.3); border-color: #ff6b6b; color: #ff6b6b; }
.opponent-hand { display: flex; flex-wrap: nowrap; }
.opponent-hand .tile.back { width: 16px; height: 24px; margin: 0; }
#player-west .opponent-hand, #player-east .opponent-hand { flex-direction: column; }
#player-west .opponent-hand .tile.back, #player-east .opponent-hand .tile.back { width: 24px; height: 16px; }
.flower-area { display: flex; gap: 1px; }
.flower-area .tile { width: 20px; height: 28px; font-size: 14px; background: linear-gradient(135deg, #fef3c7, #fde68a); border-color: #d97706; }
.meld-area { display: flex; gap: 3px; align-items: center; }
.meld-group { display: flex; gap: 0; border: 1px solid rgba(255,255,255,0.2); border-radius: 3px; padding: 1px; background: rgba(0,0,0,0.2); }
.tile.meld-tile { width: 24px; height: 34px; font-size: 17px; }

/* ===== Action bar ===== */
#action-bar { position: absolute; bottom: 90px; left: 50%; transform: translateX(-50%); display: none; gap: 6px; z-index: 80; align-items: center; justify-content: center; padding: 6px 10px; background: rgba(0,0,0,0.8); border-radius: 10px; backdrop-filter: blur(4px); }
#action-bar.show { display: flex; }
.action-btn { padding: 7px 16px; font-size: 15px; font-weight: bold; border: 2px solid transparent; border-radius: 8px; cursor: pointer; font-family: inherit; color: #fff; -webkit-tap-highlight-color: transparent; white-space: nowrap; transition: transform 0.1s, background 0.15s; }
.action-btn:active { transform: scale(0.95); }
.action-win { background: #dc2626; border-color: #fbbf24; animation: winPulse 0.8s infinite alternate; }
@keyframes winPulse { from { box-shadow: 0 0 4px rgba(251,191,36,0.4); } to { box-shadow: 0 0 16px rgba(251,191,36,0.8); } }
.action-kong { background: #7c3aed; border-color: #a78bfa; }
.action-pong { background: #2563eb; border-color: #60a5fa; }
.action-chow { background: #16a34a; border-color: #4ade80; }
.action-pass { background: #6b7280; border-color: #9ca3af; }
.action-hint { display: flex; align-items: center; gap: 5px; color: #ffd700; font-size: 12px; font-weight: bold; margin-right: 6px; white-space: nowrap; }
.action-hint .tile { width: 30px; height: 42px; font-size: 20px; border: 2px solid #fbbf24; box-shadow: 0 0 6px rgba(251,191,36,0.5); }

/* ===== Scoring ===== */
.score-detail { color: #ccc; font-size: 13px; margin: 8px 0; text-align: left; line-height: 1.8; max-width: 280px; }
.score-line { display: flex; justify-content: space-between; padding: 1px 0; border-bottom: 1px solid rgba(255,255,255,0.1); }
.score-line .fan-name { color: #fff; } .score-line .fan-val { color: #ffd700; font-weight: bold; }
.score-total { font-size: 22px; font-weight: bold; color: #fbbf24; margin-top: 10px; text-shadow: 0 0 8px rgba(251,191,36,0.5); }
.win-hand { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 10px 0; }
.win-melds, .win-tiles, .win-flowers { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; }
.win-meld-group { display: flex; gap: 0; margin-right: 6px; border: 1px solid rgba(255,255,255,0.3); border-radius: 3px; padding: 1px; }

/* ===== Overlays ===== */
#start-screen { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.85); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 100; }
#start-screen h1 { font-size: 42px; margin-bottom: 8px; }
#start-screen .subtitle { font-size: 15px; color: #aaa; margin-bottom: 28px; }
#start-screen button { padding: 12px 36px; font-size: 18px; background: #dc2626; color: #fff; border: none; border-radius: 8px; cursor: pointer; font-family: inherit; margin: 4px 0; width: 220px; }
#start-screen button:active { background: #b91c1c; }
#result-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.8); display: none; flex-direction: column; align-items: center; justify-content: center; z-index: 100; }
#result-overlay.show { display: flex; }
#result-overlay h2 { font-size: 28px; margin-bottom: 10px; }
#result-overlay button { padding: 12px 40px; font-size: 18px; background: #16a34a; color: #fff; border: none; border-radius: 8px; cursor: pointer; margin-top: 14px; font-family: inherit; }
#landscape-hint { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.92); z-index: 9999; align-items: center; justify-content: center; font-size: 20px; color: #ffd700; text-align: center; padding: 20px; }
#dice-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.88); display: none; flex-direction: column; align-items: center; justify-content: center; z-index: 200; gap: 16px; }
#dice-overlay.show { display: flex; }
.dice-title { font-size: 20px; color: #ffd700; font-weight: bold; margin-bottom: 8px; }
.dice-container { display: flex; gap: 24px; align-items: center; justify-content: center; }
.die { width: 64px; height: 64px; background: #fff; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 48px; color: #1a1a1a; box-shadow: 2px 4px 12px rgba(0,0,0,0.5); }
.die.rolling { animation: diceRoll 0.12s infinite; }
@keyframes diceRoll { 0%{transform:rotate(0) scale(1)} 25%{transform:rotate(15deg) scale(1.05)} 50%{transform:rotate(-10deg) scale(0.95)} 75%{transform:rotate(8deg) scale(1.02)} 100%{transform:rotate(0) scale(1)} }
.dice-result { font-size: 18px; color: #fff; min-height: 28px; text-align: center; }
#mute-btn { position: absolute; top: 6px; left: 6px; z-index: 50; background: rgba(0,0,0,0.5); border: none; color: #fff; font-size: 20px; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; }
#mute-btn:active { background: rgba(0,0,0,0.7); }

/* ===== Small landscape ===== */
@media (max-height: 500px) {
  #field { top: 38px; bottom: 56px; left: 38px; right: 38px; }
  #center-info { padding: 4px 8px; font-size: 10px; }
  #center-info .wind-circle { font-size: 14px; }
  .tile.hand-tile { width: 28px; height: 40px; font-size: 20px; }
  .tile.hand-tile.just-drawn { margin-left: 8px; }
  .tile.discard-tile { width: 18px; height: 25px; font-size: 11px; }
  .tile.meld-tile { width: 20px; height: 28px; font-size: 14px; }
  .melds-area .tile.meld-tile { width: 16px; height: 22px; font-size: 11px; }
  .wall-tile { width: 11px; height: 8px; }
  .wall-v .wall-tile { width: 8px; height: 11px; }
  .wall-label { font-size: 6px; }
  .opponent-hand .tile.back { width: 13px; height: 19px; }
  #player-west .opponent-hand .tile.back, #player-east .opponent-hand .tile.back { width: 19px; height: 13px; }
  .flower-area .tile { width: 16px; height: 22px; font-size: 11px; }
  .player-label { font-size: 9px; padding: 1px 5px; }
  #discard-south { bottom: 38px; max-height: calc(50% - 46px); }
  #discard-north { top: 38px; max-height: calc(50% - 46px); }
  #discard-west { left: 38px; max-width: calc(50% - 46px); }
  #discard-east { right: 38px; max-width: calc(50% - 46px); }
  #melds-south { bottom: 18px; right: 38px; }
  #melds-north { top: 18px; left: 38px; }
  #melds-west { left: 18px; bottom: 38px; }
  #melds-east { right: 18px; top: 38px; }
  #action-bar { bottom: 62px; padding: 4px 6px; gap: 4px; }
  .action-btn { padding: 5px 10px; font-size: 12px; }
  .die { width: 48px; height: 48px; font-size: 36px; }
  .dice-title { font-size: 16px; } .dice-result { font-size: 14px; }
  #mute-btn { width: 28px; height: 28px; font-size: 16px; }
  #player-north .char-avatar, #player-west .char-avatar, #player-east .char-avatar { width: 22px; height: 22px; }
  #player-north .char-avatar .char-emoji, #player-west .char-avatar .char-emoji, #player-east .char-avatar .char-emoji { font-size: 11px; }
  #player-north .player-label { font-size: 8px; padding: 1px 4px; }
  #player-north .flower-area .tile { width: 13px; height: 18px; font-size: 9px; }
}

/* ===== Very small landscape ===== */
@media (max-width: 400px) and (orientation: landscape) {
  #field { top: 32px; bottom: 48px; left: 32px; right: 32px; }
  .tile.hand-tile { width: 24px; height: 34px; font-size: 17px; }
  .tile.discard-tile { width: 15px; height: 21px; font-size: 9px; }
  .wall-tile { width: 9px; height: 7px; }
  .wall-v .wall-tile { width: 7px; height: 9px; }
  #discard-south { bottom: 32px; max-height: calc(50% - 40px); }
  #discard-north { top: 32px; max-height: calc(50% - 40px); }
  #discard-west { left: 32px; max-width: calc(50% - 40px); }
  #discard-east { right: 32px; max-width: calc(50% - 40px); }
  #melds-south { bottom: 14px; right: 32px; }
  #melds-north { top: 14px; left: 32px; }
  #melds-west { left: 14px; bottom: 32px; }
  #melds-east { right: 14px; top: 32px; }
  #player-north .char-avatar, #player-west .char-avatar, #player-east .char-avatar { width: 20px; height: 20px; }
  #player-north .char-avatar .char-emoji, #player-west .char-avatar .char-emoji, #player-east .char-avatar .char-emoji { font-size: 10px; }
  #player-north .player-label { font-size: 7px; padding: 0 3px; }
}

/* ===== Portrait phone ===== */
@media (orientation: portrait) and (max-width: 768px) {
  #field { top: 42px; bottom: 60px; left: 32px; right: 32px; }
  .tile.hand-tile { width: 28px; height: 40px; font-size: 20px; }
  .tile.hand-tile.just-drawn { margin-left: 6px; }
  .tile.discard-tile { width: 18px; height: 25px; font-size: 11px; }
  .tile.meld-tile { width: 20px; height: 28px; font-size: 14px; }
  .melds-area .tile.meld-tile { width: 16px; height: 22px; font-size: 11px; }
  .wall-tile { width: 11px; height: 8px; }
  .wall-v .wall-tile { width: 8px; height: 11px; }
  .opponent-hand .tile.back { width: 13px; height: 19px; }
  #player-west .opponent-hand .tile.back, #player-east .opponent-hand .tile.back { width: 19px; height: 13px; }
  #center-info { padding: 4px 8px; font-size: 10px; }
  #center-info .wind-circle { font-size: 14px; }
  .player-label { font-size: 9px; }
  .flower-area .tile { width: 16px; height: 22px; font-size: 11px; }
  #discard-south { bottom: 38px; max-height: calc(50% - 46px); }
  #discard-north { top: 38px; max-height: calc(50% - 46px); }
  #discard-west { left: 38px; max-width: calc(50% - 46px); }
  #discard-east { right: 38px; max-width: calc(50% - 46px); }
  #melds-south { bottom: 18px; right: 38px; }
  #melds-north { top: 18px; left: 38px; }
  #melds-west { left: 18px; bottom: 38px; }
  #melds-east { right: 18px; top: 38px; }
  #action-bar { bottom: 70px; }
  .action-btn { padding: 5px 12px; font-size: 13px; }
  #player-north .char-avatar, #player-west .char-avatar, #player-east .char-avatar { width: 22px; height: 22px; }
  #player-north .char-avatar .char-emoji, #player-west .char-avatar .char-emoji, #player-east .char-avatar .char-emoji { font-size: 11px; }
  #player-north .player-label { font-size: 8px; padding: 1px 4px; }
  #player-north .flower-area .tile { width: 13px; height: 18px; font-size: 9px; }
}

/* ===== Analysis overlay ===== */
.analysis-overlay { max-width: 380px; max-height: 80vh; overflow-y: auto; text-align: center; padding: 10px; }
.analysis-overlay h2 { font-size: 22px; margin-bottom: 6px; }
.analysis-grade { font-size: 64px; font-weight: bold; text-shadow: 0 0 20px currentColor; margin: 4px 0; }
.analysis-score { font-size: 16px; color: #ccc; margin-bottom: 4px; }
.analysis-result { font-size: 14px; color: #ffd700; margin-bottom: 12px; }
.analysis-section { background: rgba(255,255,255,0.08); border-radius: 8px; padding: 8px 12px; margin: 6px 0; text-align: left; }
.analysis-section-title { font-size: 14px; font-weight: bold; color: #ffd700; margin-bottom: 4px; }
.analysis-rating { font-weight: bold; margin-left: 4px; }
.analysis-note { font-size: 13px; color: #ddd; padding: 2px 0; }
.analysis-stats { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; color: #aaa; }
.analysis-stats span { background: rgba(255,255,255,0.1); padding: 2px 8px; border-radius: 4px; }

/* Advice timeline */
.advice-timeline { max-height: 999px; overflow: hidden; transition: max-height 0.3s; }
.advice-timeline.collapsed { max-height: 0; }
.advice-toggle { font-size: 12px; color: #aaa; cursor: pointer; font-weight: normal; margin-left: 6px; }
.advice-toggle:hover { color: #fff; }
.advice-item { padding: 6px 8px; margin: 4px 0; border-radius: 6px; border-left: 3px solid #555; }
.advice-item.advice-good { border-left-color: #22c55e; background: rgba(34,197,94,0.08); }
.advice-item.advice-ok { border-left-color: #3b82f6; background: rgba(59,130,246,0.08); }
.advice-item.advice-bad { border-left-color: #f97316; background: rgba(249,115,22,0.12); }
.advice-item.advice-mistake { border-left-color: #ef4444; background: rgba(239,68,68,0.12); }
.advice-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.advice-turn { font-size: 12px; color: #aaa; }
.advice-verdict { font-size: 13px; font-weight: bold; }
.advice-detail { font-size: 13px; color: #ddd; }
.advice-tile { color: #fff; font-weight: bold; }
.advice-suggest { color: #fbbf24; font-weight: bold; }
.advice-reason { font-size: 12px; color: #aaa; margin-top: 2px; }
.advice-meta { font-size: 11px; color: #888; margin-top: 1px; }
.advice-empty { font-size: 13px; color: #888; padding: 8px 0; text-align: center; }

/* ===== Large screen ===== */
@media (min-width: 769px) and (min-height: 501px) {
  #field { top: 60px; bottom: 85px; left: 65px; right: 65px; }
  .tile.hand-tile { width: 40px; height: 56px; font-size: 30px; }
  .tile.hand-tile.just-drawn { margin-left: 12px; }
  .tile.discard-tile { width: 26px; height: 36px; font-size: 16px; }
  .tile.meld-tile { width: 28px; height: 40px; font-size: 20px; }
  .melds-area .tile.meld-tile { width: 24px; height: 33px; font-size: 16px; }
  .wall-tile { width: 16px; height: 12px; }
  .wall-v .wall-tile { width: 12px; height: 16px; }
  .opponent-hand .tile.back { width: 20px; height: 30px; }
  #player-west .opponent-hand .tile.back, #player-east .opponent-hand .tile.back { width: 30px; height: 20px; }
  #center-info { padding: 10px 18px; font-size: 13px; }
  #center-info .wind-circle { font-size: 20px; }
  .player-label { font-size: 12px; padding: 3px 10px; }
  .flower-area .tile { width: 24px; height: 34px; font-size: 17px; }
  #discard-south { bottom: 56px; max-height: calc(50% - 66px); }
  #discard-north { top: 56px; max-height: calc(50% - 66px); }
  #discard-west { left: 56px; max-width: calc(50% - 66px); }
  #discard-east { right: 56px; max-width: calc(50% - 66px); }
  #melds-south { bottom: 26px; right: 56px; }
  #melds-north { top: 26px; left: 56px; }
  #melds-west { left: 26px; bottom: 56px; }
  #melds-east { right: 26px; top: 56px; }
  #action-bar { bottom: 110px; }
  .action-btn { padding: 10px 22px; font-size: 17px; }
  #player-north .char-avatar, #player-west .char-avatar, #player-east .char-avatar { width: 32px; height: 32px; }
  #player-north .char-avatar .char-emoji, #player-west .char-avatar .char-emoji, #player-east .char-avatar .char-emoji { font-size: 16px; }
  #player-north .player-label { font-size: 11px; }
}
/* ===== Lobby / Multiplayer ===== */
#start-screen .name-input-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
#start-screen .name-input-row label { font-size: 14px; color: #ccc; white-space: nowrap; }
#start-screen .name-input-row input { padding: 8px 12px; font-size: 16px; border: 1px solid #555; border-radius: 6px; background: #333; color: #fff; font-family: inherit; width: 160px; text-align: center; }
#start-screen .name-input-row input::placeholder { color: #777; }
#start-screen .btn-secondary { background: #555 !important; }
#start-screen .btn-secondary:active { background: #444 !important; }
/* === Lobby & Chatroom styles === */
.lobby-error { color: #ef4444; font-size: 13px; margin-top: 8px; min-height: 18px; }
.seat-wind { font-weight: bold; color: #ffd700; min-width: 20px; }
#menu-login, #menu-lobby-list, #menu-chatroom { display: flex; flex-direction: column; align-items: center; width: 100%; }

/* 遊戲大廳 */
.lobby-list-title { font-size: 18px; color: #ffd700; margin-bottom: 8px; font-weight: bold; }
.room-list { width: 100%; max-width: 320px; max-height: 200px; overflow-y: auto; margin-bottom: 8px; -webkit-overflow-scrolling: touch; }
.room-list-empty { color: #777; font-size: 14px; text-align: center; padding: 16px 0; }
.room-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; margin: 4px 0; border-radius: 8px; background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); cursor: pointer; transition: background 0.2s; }
.room-item:hover, .room-item:active { background: rgba(34,197,94,0.25); }
.room-item-disabled { opacity: 0.5; cursor: default; }
.room-item-disabled:hover { background: rgba(34,197,94,0.1); }
.room-code-tag { font-weight: bold; color: #ffd700; font-size: 14px; min-width: 50px; letter-spacing: 2px; }
.room-players { font-size: 13px; color: #22c55e; font-weight: bold; }
.room-status-waiting { color: #4ade80; font-size: 12px; }
.room-status-playing { color: #fbbf24; font-size: 12px; }
.room-join-row { display: flex; gap: 6px; width: 100%; max-width: 320px; margin: 6px 0; }
.room-join-row input { flex: 1; }
.btn-small-text { font-size: 13px; padding: 6px 12px; }

/* 聊天室 */
.chatroom-header { display: flex; justify-content: space-between; align-items: center; width: 100%; max-width: 320px; margin-bottom: 6px; }
.chatroom-code { font-size: 16px; color: #ffd700; font-weight: bold; }
.btn-small { font-size: 12px; padding: 4px 10px; background: #555; color: #fff; border: none; border-radius: 6px; cursor: pointer; }
.btn-small:active { background: #444; }
.chatroom-seats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; width: 100%; max-width: 320px; margin-bottom: 6px; }
.chatroom-seat { padding: 6px 10px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.15); font-size: 13px; color: #ccc; display: flex; align-items: center; gap: 4px; }
.chatroom-seat.occupied { border-color: rgba(34,197,94,0.5); color: #fff; }
.chatroom-seat.ready { background: rgba(74,222,128,0.15); border-color: #4ade80; }
.chatroom-seat.ai { border-color: rgba(251,191,36,0.4); color: #fbbf24; }
.chatroom-seat.empty { color: #555; border-color: rgba(255,255,255,0.08); }
.chatroom-messages { width: 100%; max-width: 320px; height: 120px; overflow-y: auto; background: rgba(0,0,0,0.35); border-radius: 8px; padding: 8px; margin-bottom: 6px; font-size: 13px; -webkit-overflow-scrolling: touch; }
.chat-msg { margin: 2px 0; line-height: 1.4; word-break: break-word; }
.chat-msg .chat-name { color: #4ade80; font-weight: bold; }
.chat-msg.system { color: #94a3b8; font-style: italic; font-size: 12px; }
.chatroom-input-row { display: flex; gap: 6px; width: 100%; max-width: 320px; margin-bottom: 6px; }
.chatroom-input-row input { flex: 1; font-size: 14px; padding: 6px 10px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.2); background: rgba(0,0,0,0.3); color: #fff; }
.chatroom-input-row button { padding: 6px 14px; font-size: 14px; border-radius: 8px; background: #22c55e; color: #fff; border: none; cursor: pointer; }
.chatroom-input-row button:active { background: #16a34a; }
#ready-btn { width: 100%; max-width: 320px; font-size: 16px; padding: 10px; }
#ready-btn.is-ready { background: #ef4444 !important; }
#ready-btn.is-ready:active { background: #dc2626 !important; }

/* PWA standalone: hide fullscreen btn, no safe-area padding needed */
@media all and (display-mode: standalone), all and (display-mode: fullscreen) {
  html, body { padding: 0 !important; }
  #fullscreen-btn { display: none !important; }
  #pwa-hint { display: none !important; }
}
@keyframes fadeInUp { from { opacity:0; transform:translateX(-50%) translateY(20px); } to { opacity:1; transform:translateX(-50%) translateY(0); } }

/* Fullscreen button */
#fullscreen-btn {
  position: fixed;
  top: 10px;
  right: 50px;
  z-index: 9999;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
#fullscreen-btn:hover { background: rgba(0,0,0,0.7); }


/* ===== v28: Touch highlight ===== */
.tile.hand-tile.touch-highlight {
  transform: translateY(-8px);
  box-shadow: 0 0 10px rgba(100,200,255,0.7);
  border-color: #60a5fa;
  transition: transform 0.08s, box-shadow 0.08s;
}

/* ===== v28: VFX Action Popup ===== */
.vfx-action-popup {
  position: absolute;
  font-size: 36px;
  font-weight: 900;
  pointer-events: none;
  z-index: 500;
  transform: translate(-50%, -50%) scale(0.3);
  opacity: 0;
  transition: none;
  white-space: nowrap;
  font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}
.vfx-action-popup.vfx-animate {
  animation: vfxPop 1.2s ease-out forwards;
}
@keyframes vfxPop {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
  15% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
  30% { transform: translate(-50%, -50%) scale(1.0); opacity: 1; }
  100% { transform: translate(-50%, -70%) scale(1.0); opacity: 0; }
}

/* ===== v28: Turn indicator ===== */
.turn-active {
  position: relative;
}
.turn-active::after {
  content: '';
  position: absolute;
  inset: -3px;
  border: 2px solid rgba(251,191,36,0.6);
  border-radius: 10px;
  pointer-events: none;
  animation: turnGlow 1.5s infinite alternate;
}
@keyframes turnGlow {
  from { border-color: rgba(251,191,36,0.3); box-shadow: 0 0 4px rgba(251,191,36,0.2); }
  to { border-color: rgba(251,191,36,0.8); box-shadow: 0 0 12px rgba(251,191,36,0.5); }
}

/* ===== v28: Larger touch targets on mobile ===== */
@media (pointer: coarse) {
  .action-btn { min-height: 44px; min-width: 44px; padding: 10px 18px; font-size: 16px; }
  .tile.hand-tile { min-width: 32px; }
}

/* ===== v28: Small screen action popup ===== */
@media (max-height: 500px) {
  .vfx-action-popup { font-size: 24px; }
}

/* ===== v29: Mini hand display in analysis ===== */
.advice-hand {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-items: center;
  margin: 4px 0 2px;
  padding: 4px 6px;
  background: rgba(0,0,0,0.25);
  border-radius: 4px;
}
.mini-tile {
  display: inline-block;
  font-size: 13px;
  padding: 1px 3px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 3px;
  line-height: 1.3;
  white-space: nowrap;
}
.mini-discard {
  background: rgba(239,68,68,0.3);
  border-color: #ef4444;
  color: #fca5a5;
}
.mini-suggest {
  background: rgba(34,197,94,0.3);
  border-color: #22c55e;
  color: #86efac;
}
.mini-meld {
  background: rgba(59,130,246,0.2);
  border-color: rgba(59,130,246,0.4);
  color: #93c5fd;
}
.advice-meld {
  display: inline-flex;
  gap: 1px;
}
.advice-meld-sep {
  color: rgba(255,255,255,0.3);
  margin: 0 3px;
  font-size: 14px;
}

/* ===== v30: Score display ===== */
.score-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  margin-top: 3px;
}
.score-item {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255,255,255,0.08);
  white-space: nowrap;
}
.score-pos { color: #4ade80; }
.score-neg { color: #f87171; }

/* Round standings in end screen */
.round-standings {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin: 8px 0;
}
.standing-item {
  font-size: 13px;
  padding: 3px 10px;
  border-radius: 6px;
  background: rgba(255,255,255,0.1);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.standing-avatar {
  display: inline-block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid;
  overflow: hidden;
  vertical-align: middle;
  flex-shrink: 0;
}
.standing-avatar svg {
  width: 100%;
  height: 100%;
}

/* Final ranking */
.final-ranking {
  margin: 12px 0;
  min-width: 240px;
}
.rank-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  margin: 4px 0;
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  font-size: 16px;
}
.rank-medal { font-size: 20px; min-width: 30px; }
.rank-name { flex: 1; text-align: left; margin-left: 4px; }
.rank-score { font-weight: bold; min-width: 60px; text-align: right; }

/* Quit button */
.btn-quit {
  background: #6b7280 !important;
  font-size: 14px !important;
  padding: 8px 16px !important;
}
.btn-quit:active { background: #4b5563 !important; }

/* ===== v32: AI Watch mode ===== */
.opponent-hand .opp-tile {
  width: 20px;
  height: 28px;
  font-size: 13px;
  cursor: default;
  margin: 0;
}
#player-west .opponent-hand .opp-tile,
#player-east .opponent-hand .opp-tile {
  width: 24px;
  height: 16px;
  font-size: 10px;
}

/* ===== v34: AI Watch rounds counter ===== */
.watch-rounds {
  color: #ffd700;
  font-size: 13px;
  font-weight: bold;
  margin-top: 2px;
  text-shadow: 0 0 6px rgba(255,215,0,0.5);
}
/* ===== v37: 明星三缺一 Style Start Screen ===== */
#start-screen {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; align-items: flex-start; justify-content: center;
  z-index: 100; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 12px 0;
}
#start-screen .start-bg {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at 50% 40%, #1a6b30 0%, #0d4a1a 50%, #072e0f 100%);
  z-index: 0;
}
#start-screen .start-bg::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background-image: radial-gradient(circle at 20% 80%, rgba(255,215,0,0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255,215,0,0.03) 0%, transparent 50%);
}
#start-screen .start-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 14px; max-width: 340px; width: calc(100% - 24px);
  margin: auto;
  background: linear-gradient(180deg, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0.4) 100%);
  border: 2px solid rgba(255,215,0,0.25);
  border-radius: 20px;
  box-shadow: 0 0 40px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,215,0,0.1);
  flex-shrink: 0;
}
#start-screen .start-logo {
  font-size: 40px; margin-bottom: 0;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.6));
  animation: logoFloat 3s ease-in-out infinite;
}
@keyframes logoFloat { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-5px)} }
#start-screen h1 {
  font-size: 22px; font-weight: 900; margin: 2px 0 0;
  color: #ffd700;
  text-shadow: 0 2px 8px rgba(255,215,0,0.3), 0 0 2px rgba(0,0,0,0.8);
  letter-spacing: 6px;
}
#start-screen .subtitle {
  font-size: 11px; color: rgba(255,215,0,0.5); margin-bottom: 8px;
  letter-spacing: 3px; font-weight: bold;
}
#start-screen .name-input-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px; width: 100%; max-width: 280px;
}
#start-screen .name-input-row label { display: none; }
#start-screen .name-input-row input {
  width: 100%; padding: 10px 14px; font-size: 16px;
  border: 2px solid rgba(255,215,0,0.35); border-radius: 10px;
  background: rgba(0,0,0,0.5); color: #fff; font-family: inherit;
  text-align: center; outline: none; transition: border-color 0.2s;
}
#start-screen .name-input-row input:focus { border-color: #ffd700; box-shadow: 0 0 8px rgba(255,215,0,0.3); }
#start-screen .name-input-row input::placeholder { color: rgba(255,255,255,0.3); }
#start-screen .btn-primary {
  width: 100%; max-width: 280px; padding: 10px 24px; font-size: 18px; font-weight: 900;
  background: linear-gradient(180deg, #e53e3e 0%, #c53030 50%, #9b2c2c 100%);
  color: #fff; border: 2px solid rgba(255,215,0,0.5); border-radius: 12px;
  cursor: pointer; font-family: inherit; margin: 4px 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.2);
  text-shadow: 0 1px 3px rgba(0,0,0,0.5); letter-spacing: 2px;
  transition: transform 0.1s;
}
#start-screen .btn-primary:active { transform: scale(0.96); }
#start-screen .btn-ai {
  width: 100%; max-width: 280px; padding: 10px 24px; font-size: 16px; font-weight: 900;
  background: linear-gradient(180deg, #805ad5 0%, #6b46c1 50%, #553c9a 100%);
  color: #fff; border: 2px solid rgba(255,215,0,0.3); border-radius: 12px;
  cursor: pointer; font-family: inherit; margin: 4px 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.15);
  text-shadow: 0 1px 3px rgba(0,0,0,0.5); letter-spacing: 2px;
  transition: transform 0.1s;
}
#start-screen .btn-ai:active { transform: scale(0.96); }
#start-screen .btn-row { display: flex; gap: 8px; width: 100%; max-width: 280px; margin-top: 4px; }
#start-screen .btn-row .btn-secondary { flex: 1; }
#start-screen .btn-secondary {
  padding: 10px 12px; font-size: 14px; font-weight: bold;
  background: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0.05) 100%);
  color: #ddd; border: 1px solid rgba(255,215,0,0.2); border-radius: 10px;
  cursor: pointer; font-family: inherit; margin: 3px 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3); transition: transform 0.1s; width: 100%;
}
#start-screen .btn-secondary:active { transform: scale(0.96); background: rgba(255,255,255,0.15); }
#start-screen button { border-radius: 10px; font-family: inherit; }
#menu-login, #menu-lobby-list, #menu-chatroom { display: flex; flex-direction: column; align-items: center; width: 100%; }

/* ===== v37: Fullscreen button — show PWA hint on mobile ===== */
#fullscreen-btn.pwa-mode {
  width: auto; border-radius: 8px; padding: 6px 12px; font-size: 12px;
  right: 6px; top: 6px; white-space: nowrap;
}

/* ===== v42: Character Avatars ===== */
.char-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  border: 2.5px solid #ffd700; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.2);
  flex-shrink: 0; overflow: hidden;
}
.char-avatar svg { width: 100%; height: 100%; }
.char-avatar-sm { width: 36px; height: 36px; }
.char-emoji { font-size: 24px; line-height: 1; }
.char-avatar-sm .char-emoji { font-size: 18px; }
#player-north .char-avatar, #player-west .char-avatar, #player-east .char-avatar {
  width: 28px; height: 28px; margin-bottom: 0;
}
#player-north .char-avatar .char-emoji, #player-west .char-avatar .char-emoji, #player-east .char-avatar .char-emoji {
  font-size: 14px;
}
#player-north .player-label { font-size: 10px; padding: 1px 6px; }
#player-north .opponent-hand { margin-left: 2px; }
#player-north .flower-area { margin-left: 2px; }
#player-north .flower-area .tile { width: 16px; height: 22px; font-size: 11px; }
#player-north .danger-badge { font-size: 9px; padding: 1px 4px; }

/* ===== v39: Speech Bubbles ===== */
.speech-bubble {
  position: absolute; z-index: 60;
  background: #fff; color: #1a1a1a; font-size: 13px; font-weight: bold;
  padding: 4px 10px; border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  white-space: nowrap; pointer-events: none;
  opacity: 0; transform: scale(0.5) translateY(4px);
  transition: opacity 0.2s, transform 0.2s;
}
.speech-bubble.show {
  opacity: 1; transform: scale(1) translateY(0);
}
.speech-bubble::after {
  content: ''; position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
  border-left: 6px solid transparent; border-right: 6px solid transparent;
  border-top: 6px solid #fff;
}
#player-south .speech-bubble { bottom: 100%; left: 50%; transform-origin: bottom center; margin-bottom: 4px; }
#player-south .speech-bubble.show { transform: scale(1) translateX(-50%); }
#player-south .speech-bubble { transform: scale(0.5) translateX(-50%) translateY(4px); }
#player-north .speech-bubble { top: 100%; margin-top: 4px; }
#player-north .speech-bubble::after { bottom: auto; top: -6px; border-top: none; border-bottom: 6px solid #fff; }
#player-west .speech-bubble { left: 100%; top: 50%; margin-left: 4px; transform-origin: left center; }
#player-west .speech-bubble::after { left: -6px; top: 50%; bottom: auto; transform: translateY(-50%); border: none; border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-right: 6px solid #fff; }
#player-east .speech-bubble { right: 100%; top: 50%; margin-right: 4px; transform-origin: right center; }
#player-east .speech-bubble::after { right: -6px; left: auto; top: 50%; bottom: auto; transform: translateY(-50%); border: none; border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-left: 6px solid #fff; }

/* ===== v38: Music button ===== */
#music-btn {
  position: fixed; top: 6px; right: 80px; z-index: 90;
  background: rgba(0,0,0,0.5); color: #fff; border: 1px solid rgba(255,255,255,0.3);
  border-radius: 50%; width: 36px; height: 36px; font-size: 18px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

/* ===== v40: Danger Badge on Opponents ===== */
.danger-badge {
  position: absolute; top: -2px; right: -2px; z-index: 55;
  color: #fff; font-size: 10px; font-weight: bold;
  padding: 1px 5px; border-radius: 8px;
  animation: dangerPulse 1.5s ease-in-out infinite;
  cursor: pointer; white-space: nowrap;
  pointer-events: auto;
}
@keyframes dangerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ===== v40: Live Danger Panel ===== */
#danger-panel {
  position: fixed; bottom: 70px; left: 4px; right: 4px; z-index: 85;
  pointer-events: auto;
}
.danger-summary {
  display: flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,0.85); border: 1px solid rgba(239,68,68,0.4);
  border-radius: 12px; padding: 5px 12px; cursor: pointer;
  font-size: 12px; color: #fbbf24;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.danger-icon { font-size: 14px; }
.danger-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.danger-arrow { font-size: 10px; color: #888; }
.danger-detail {
  background: rgba(0,0,0,0.92); border: 1px solid rgba(239,68,68,0.3);
  border-radius: 12px; margin-top: 4px; padding: 8px;
  max-height: 45vh; overflow-y: auto;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.danger-card {
  background: rgba(255,255,255,0.05); border-radius: 8px;
  padding: 6px 8px; margin-bottom: 6px;
}
.danger-card:last-child { margin-bottom: 0; }
.danger-card-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: bold; margin-bottom: 4px;
}
.danger-level-tag {
  font-size: 10px; color: #fff; padding: 1px 6px;
  border-radius: 6px; font-weight: bold;
}
.danger-row { font-size: 11px; color: #ddd; margin: 3px 0; line-height: 1.5; }
.danger-row.tip { color: #aaa; font-size: 10px; }
.dtile {
  display: inline-block; font-size: 11px; padding: 1px 4px;
  border-radius: 3px; margin: 1px 2px; font-weight: bold;
}
.dtile.hot { background: rgba(239,68,68,0.4); border: 1px solid #ef4444; color: #fca5a5; }
.dtile.warn { background: rgba(245,158,11,0.3); border: 1px solid #f59e0b; color: #fde68a; }

/* Landscape adjustments for danger panel */
@media (orientation: landscape) {
  #danger-panel { bottom: 60px; left: 60px; right: 60px; }
}
@media (max-height: 400px) {
  .danger-detail { max-height: 30vh; }
  .danger-summary { padding: 3px 8px; font-size: 11px; }
}

/* ===== v43: Tile Danger Indicators ===== */
.hand-tile { position: relative; }
.tile-danger-dot {
  position: absolute; top: -4px; right: -2px; z-index: 10;
  font-size: 8px; font-weight: bold; min-width: 16px;
  text-align: center; padding: 0 3px; border-radius: 8px;
  line-height: 14px; pointer-events: none;
}
.tile-danger-dot.hot {
  background: rgba(239,68,68,0.9); color: #fff;
  animation: dangerPulse 1.5s ease-in-out infinite;
}
.tile-danger-dot.warn {
  background: rgba(245,158,11,0.85); color: #fff;
}
.tile-danger-dot.safe {
  background: rgba(34,197,94,0.8); color: #fff;
}
.best-discard {
  box-shadow: 0 0 8px 2px rgba(250,204,21,0.7), 0 0 2px 1px rgba(250,204,21,0.4);
  border-color: #facc15 !important;
}
.best-discard::after {
  content: '★';
  position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
  font-size: 10px; color: #facc15; text-shadow: 0 0 4px rgba(0,0,0,0.8);
  pointer-events: none; z-index: 10;
}

/* ===== v43: Risk Indicator Toggle Button ===== */
#risk-btn {
  position: fixed; top: 6px; right: 116px; z-index: 90;
  background: rgba(0,0,0,0.5); color: #fff; border: 1px solid rgba(255,255,255,0.3);
  border-radius: 50%; width: 36px; height: 36px; font-size: 18px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
#quit-btn {
  position: fixed; top: 6px; right: 152px; z-index: 90;
  background: rgba(0,0,0,0.5); color: #f87171; border: 1px solid rgba(248,113,113,0.4);
  border-radius: 50%; width: 36px; height: 36px; font-size: 18px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent; display: none;
}
#quit-btn:active { background: rgba(244,67,54,0.3); }

/* ===== v46: Mobile start screen — compact for small screens ===== */
@media (max-height: 440px) {
  #start-screen { padding: 4px 0; }
  #start-screen .start-content { padding: 8px 12px; border-radius: 14px; }
  #start-screen .start-logo { font-size: 28px; }
  #start-screen h1 { font-size: 18px; letter-spacing: 4px; margin: 0; }
  #start-screen .subtitle { font-size: 10px; margin-bottom: 4px; }
  #start-screen .name-input-row { margin-bottom: 6px; }
  #start-screen .name-input-row input { padding: 6px 10px; font-size: 14px; }
  #start-screen .btn-primary { padding: 7px 16px; font-size: 15px; margin: 2px 0; }
  #start-screen .btn-ai { padding: 6px 16px; font-size: 14px; margin: 2px 0; }
  #start-screen .btn-row { margin-top: 2px; gap: 6px; }
  #start-screen .btn-secondary { padding: 6px 8px; font-size: 12px; margin: 1px 0; }
}
@media (max-height: 340px) {
  #start-screen .start-logo { font-size: 22px; }
  #start-screen h1 { font-size: 16px; letter-spacing: 3px; }
  #start-screen .subtitle { display: none; }
  #start-screen .start-content { padding: 6px 10px; }
  #start-screen .btn-primary { padding: 5px 12px; font-size: 14px; }
  #start-screen .btn-ai { padding: 5px 12px; font-size: 13px; }
  #start-screen .btn-secondary { padding: 5px 6px; font-size: 11px; }
}
