/**
 * All Fives Dominoes — Styles
 * @author Keith Adler
 * @copyright 2026 Keith Adler. MIT License.
 * @see https://github.com/keithadler/dominoes27
 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800;900&display=swap');
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: #0a2e14;
  color: #fff; height: 100vh; height: 100dvh; overflow: hidden; user-select: none;
  -webkit-user-select: none; -webkit-touch-callout: none;
}
/* 1. Rich felt table with vignette */
body::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 50%, transparent 40%, rgba(0,0,0,0.5) 100%),
    radial-gradient(ellipse at 50% 50%, #1e7a35 0%, #145a24 40%, #0d3a18 80%);
}
body::after {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg width='80' height='80' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='6' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='80' height='80' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* 24. Smooth screen transitions */
.screen { display: none; width: 100%; height: 100vh; height: 100dvh; position: relative; z-index: 1; opacity: 0; transition: opacity 0.3s ease; }
.screen.active { display: flex; opacity: 1; }

/* 22. Menu ambient glow */
.menu-container {
  margin: auto; text-align: center;
  background: linear-gradient(145deg, rgba(10,10,10,0.7), rgba(0,0,0,0.85));
  padding: 44px 54px; border-radius: 28px;
  backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 0 80px rgba(232,167,53,0.08), 0 30px 80px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.04);
  max-height: 95vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.title-wrap {
  display: flex; align-items: center; justify-content: center; gap: 20px; margin-bottom: 8px;
}
.title-tile {
  opacity: 0.6; filter: drop-shadow(0 0 12px rgba(232,167,53,0.3));
  animation: titleTileFloat 3s ease-in-out infinite alternate;
}
.title-tile:last-of-type { animation-delay: 1.5s; }
@keyframes titleTileFloat {
  0% { transform: translateY(0) rotate(-2deg); }
  100% { transform: translateY(-6px) rotate(2deg); }
}
.game-title {
  font-size: 3.8rem; letter-spacing: 10px; margin-bottom: 2px; font-weight: 900;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5), 0 0 80px rgba(232,167,53,0.3);
  background: linear-gradient(180deg, #fff 10%, #f0b840 45%, #c09830 70%, #8a6a20);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  line-height: 1.1;
}
.subtitle {
  font-size: 1.3rem; opacity: 0.45; margin-bottom: 36px; letter-spacing: 14px;
  text-transform: uppercase; font-weight: 400; text-align: center;
  background: linear-gradient(180deg, rgba(255,255,255,0.6), rgba(255,255,255,0.25));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.option-group { margin-bottom: 20px; text-align: left; }
.option-group label { display: block; margin-bottom: 8px; font-size: 0.8rem; opacity: 0.4; text-transform: uppercase; letter-spacing: 2px; font-weight: 600; }
.btn-group { display: flex; gap: 8px; }

/* 25. Polished button micro-interactions */
.btn-option {
  flex: 1; padding: 12px 16px; border: 2px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04); color: rgba(255,255,255,0.8); border-radius: 12px;
  cursor: pointer; font-size: 0.95rem; font-weight: 600;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.btn-option:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); transform: translateY(-2px); }
.btn-option.active {
  background: linear-gradient(145deg, #f0b840, #d4922a); border-color: transparent;
  color: #1a1a1a; font-weight: 800;
  box-shadow: 0 4px 20px rgba(232,167,53,0.35), inset 0 1px 0 rgba(255,255,255,0.3);
}
/* 14. Premium button with shine */
.btn-start {
  margin-top: 28px; padding: 18px 56px;
  background: linear-gradient(145deg, #f0b840, #d4922a); color: #1a1a1a;
  border: none; border-radius: 14px; font-size: 1.2rem; font-weight: 800;
  cursor: pointer; letter-spacing: 1.5px; position: relative; overflow: hidden;
  box-shadow: 0 8px 30px rgba(232,167,53,0.4), inset 0 1px 0 rgba(255,255,255,0.3);
  transition: all 0.2s;
}
.btn-start::after {
  content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
  background: linear-gradient(45deg, transparent 40%, rgba(255,255,255,0.15) 50%, transparent 60%);
  animation: btnShine 3s ease-in-out infinite;
}
@keyframes btnShine { 0% { transform: translateX(-100%) rotate(0); } 100% { transform: translateX(100%) rotate(0); } }
.btn-start:hover { transform: scale(1.05) translateY(-2px); box-shadow: 0 12px 40px rgba(232,167,53,0.5); }

/* Roster */
#player-roster { margin-top: 22px; padding: 18px; border-radius: 16px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.05); text-align: left; }
#player-roster .roster-title { font-size: 0.7rem; opacity: 0.35; text-transform: uppercase; letter-spacing: 2px; margin-bottom: 12px; text-align: center; font-weight: 700; }
.roster-card { display: flex; align-items: center; gap: 16px; padding: 12px 16px; margin: 8px 0; border-radius: 14px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.04); transition: all 0.3s; }
.roster-card:hover { background: rgba(255,255,255,0.06); transform: translateX(4px); }
.roster-card.human { border-color: rgba(232,167,53,0.25); background: rgba(232,167,53,0.06); }
.roster-card .roster-avatar { width: 64px; height: 64px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.08); flex-shrink: 0; }
.roster-card .roster-info { flex: 1; }
.roster-card .roster-name { font-weight: 800; font-size: 1.05rem; }
.roster-card .roster-rank { font-size: 0.8rem; opacity: 0.5; margin-top: 3px; }
.roster-card .roster-record { font-size: 0.75rem; opacity: 0.3; font-family: 'Inter', monospace; }

/* ---- Game Screen ---- */
#game-screen { flex-direction: column; position: relative; }

/* 7/16. Score bar with glass morphism + gold shimmer */
#score-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; flex-shrink: 0; z-index: 2;
  background: linear-gradient(180deg, rgba(0,0,0,0.6), rgba(0,0,0,0.4));
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(232,167,53,0.1);
  box-shadow: 0 2px 20px rgba(0,0,0,0.3);
  font-size: 0.95rem; position: relative; overflow: hidden;
}
#score-bar::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(232,167,53,0.04), transparent);
  animation: shimmer 4s ease-in-out infinite;
}
#score-bar-content {
  display: flex; align-items: center; gap: 12px; flex: 1;
  justify-content: center; flex-wrap: wrap;
}
.sb-round {
  font-weight: 900; font-size: 1.3rem; letter-spacing: 1px;
  background: linear-gradient(180deg, #ffe080, #f0b840);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
@keyframes shimmer { 0%,100% { transform: translateX(-100%); } 50% { transform: translateX(100%); } }
.sb-team, .sb-player-score {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 20px; border-radius: 12px;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(8px);
}
.sb-team-name, .sb-ps-name { font-weight: 700; opacity: 0.7; font-size: 0.9rem; }
/* 10. Gradient text on scores */
.sb-team-score, .sb-ps-score {
  font-weight: 900; font-size: 1.5rem;
  background: linear-gradient(180deg, #ffe080, #f0b840, #c07800);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.sb-vs { opacity: 0.2; font-weight: 800; font-size: 0.9rem; letter-spacing: 2px; }
.sb-target { opacity: 0.25; font-size: 0.7rem; font-weight: 600; letter-spacing: 1px; }

/* 15. Smoother thinking dots */
.thinking-dots { display: inline-flex; gap: 5px; align-items: center; margin-left: 6px; }
.thinking-dots span {
  width: 10px; height: 10px; border-radius: 50%;
  background: #f0b840;
  animation: thinkBlink 1.4s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.25s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.5s; }
@keyframes thinkBlink { 0%,100% { opacity: 0.15; transform: scale(0.7); } 50% { opacity: 1; transform: scale(1.3); } }
/* Thinking overlay — positioned near AI player */
#thinking-overlay {
  position: fixed;
  z-index: 12; pointer-events: none;
}
#thinking-overlay.hidden { display: none; }
.think-card {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 24px; border-radius: 14px;
  background: linear-gradient(145deg, rgba(10,10,10,0.85), rgba(0,0,0,0.9));
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  animation: thinkCardIn 0.3s ease-out;
}
@keyframes thinkCardIn { from { opacity: 0; transform: scale(0.9) translateY(10px); } }
.think-card .think-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid rgba(232,167,53,0.4);
}
.think-card .think-info { display: flex; flex-direction: column; }
.think-card .think-name { font-weight: 800; font-size: 0.9rem; color: #f0b840; }
.think-card .think-label {
  display: flex; align-items: center; gap: 5px;
  font-size: 0.8rem; opacity: 0.7; margin-top: 1px;
}
.think-card .thinking-dots-lg { display: inline-flex; gap: 6px; align-items: center; }
.think-card .thinking-dots-lg span {
  width: 12px; height: 12px; border-radius: 50%;
  background: #f0b840;
  animation: thinkBlink 1.4s ease-in-out infinite;
}
.think-card .thinking-dots-lg span:nth-child(2) { animation-delay: 0.25s; }
.think-card .thinking-dots-lg span:nth-child(3) { animation-delay: 0.5s; }

/* Hide the small thinking indicator in opponent panels */
.opp-thinking { display: none; }

/* Main game grid */
#game-layout { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }

/* 9. Frosted glass opponent panels — compact */
.opponent-hand { display: flex; align-items: center; justify-content: center; gap: 3px; padding: 4px 8px; flex-shrink: 0; min-height: 0; }
.opponent-hand.top {
  background: linear-gradient(180deg, rgba(0,0,0,0.35), transparent);
  backdrop-filter: blur(6px);
  min-height: 70px; padding: 6px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.opponent-hand.left, .opponent-hand.right {
  flex-direction: column; width: 80px; flex-shrink: 0; padding: 6px 4px;
  backdrop-filter: blur(6px);
}
.opponent-hand.left { background: linear-gradient(90deg, rgba(0,0,0,0.3), transparent); border-right: 1px solid rgba(255,255,255,0.03); }
.opponent-hand.right { background: linear-gradient(-90deg, rgba(0,0,0,0.3), transparent); border-left: 1px solid rgba(255,255,255,0.03); }

/* 8. Avatar ring glow for active turn */
.opp-label { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 4px; }
.opp-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.08);
  transition: all 0.4s;
}
.opp-label.active-turn .opp-avatar {
  border-color: #f0b840;
  box-shadow: 0 0 20px rgba(232,167,53,0.5), 0 0 40px rgba(232,167,53,0.15);
  animation: avatarPulse 2s ease-in-out infinite;
}
@keyframes avatarPulse { 0%,100% { box-shadow: 0 0 20px rgba(232,167,53,0.5), 0 0 40px rgba(232,167,53,0.15); } 50% { box-shadow: 0 0 30px rgba(232,167,53,0.7), 0 0 60px rgba(232,167,53,0.25); } }
.opp-info { display: flex; flex-direction: column; text-align: left; }
.opp-name { font-weight: 800; font-size: 0.8rem; color: rgba(255,255,255,0.9); }
.opp-name.active-turn { color: #f0b840; }
.opp-score { font-weight: 900; font-size: 1rem; background: linear-gradient(180deg, #ffe080, #f0b840); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.opp-record { font-size: 0.55rem; opacity: 0.35; font-family: 'Inter', monospace; }
.opponent-hand.left .opp-label, .opponent-hand.right .opp-label { flex-direction: column; gap: 4px; }
.opponent-hand.left .opp-info, .opponent-hand.right .opp-info { text-align: center; }

/* Human info bar — single row with controls */
#human-info {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 4px 16px;
  background: linear-gradient(0deg, rgba(0,0,0,0.6), rgba(0,0,0,0.3));
  backdrop-filter: blur(6px);
  border-radius: 0;
  margin: 0;
  position: relative; z-index: 5;
  pointer-events: auto;
}
#human-info .human-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  border: 3px solid rgba(232,167,53,0.3); background: rgba(255,255,255,0.08);
  transition: all 0.4s;
}
#human-info .human-name { font-weight: 800; font-size: 0.9rem; }
#human-info .human-score { font-weight: 900; font-size: 1.4rem; line-height: 1.1; background: linear-gradient(180deg, #ffe080, #f0b840); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
#human-info .human-record { font-size: 0.6rem; opacity: 0.3; font-family: 'Inter', monospace; }
#human-info .human-info-text { display: flex; flex-direction: column; }
#player-controls { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* 17. Face-down tiles — compact 3D */
.face-down {
  width: 30px; height: 15px;
  background: linear-gradient(160deg, #f8f4e4 0%, #e8e0c4 30%, #d0c8a8 70%, #c0b890 100%);
  border: 1.5px solid rgba(180,170,140,0.4);
  border-radius: 4px; flex-shrink: 0; position: relative;
  box-shadow:
    0 1px 0 #b8b090, 0 2px 0 #a8a080,
    0 3px 8px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.8),
    inset 0 -1px 2px rgba(0,0,0,0.06);
}
.face-down::before {
  content: '◆'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 5px; color: rgba(160,140,100,0.2); font-weight: 900;
}
.face-down::after {
  content: ''; position: absolute; inset: 2px;
  border: 1px solid rgba(160,140,100,0.1); border-radius: 2px;
}
.face-down.vertical { width: 15px; height: 30px; }
.face-down.teammate {
  background: linear-gradient(160deg, #e0f8e8 0%, #b8e8c0 30%, #90d0a0 70%, #78c088 100%);
  border-color: rgba(100,180,120,0.35);
  box-shadow: 0 1px 0 #78b088, 0 2px 0 #68a078, 0 3px 8px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.7), inset 0 -1px 2px rgba(0,0,0,0.06);
}

/* Middle row */
#game-middle { flex: 1; display: flex; min-height: 0; overflow: hidden; }
#center-area { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
/* 2/3/12. Board with wood rail + sunken feel + ambient glow */
#board-area {
  flex: 1; position: relative; overflow: hidden; min-height: 0;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.3), inset 0 0 80px rgba(0,0,0,0.1), 0 0 30px rgba(30,122,53,0.1);
  border-radius: 0;
  background: radial-gradient(ellipse at center, rgba(30,130,55,0.15), transparent 70%);
}
#board-canvas { display: block; }

/* 14. Boneyard — compact inline in control bar */
#boneyard-area {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}
#boneyard-tiles { position: relative; width: 60px; height: 24px; }
#boneyard-label {
  font-size: 0.85rem; white-space: nowrap; flex-shrink: 0; font-weight: 800; letter-spacing: 0.5px;
  display: flex; align-items: center; gap: 6px;
}
#boneyard-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px; padding: 0 6px;
  background: linear-gradient(145deg, rgba(232,167,53,0.25), rgba(232,167,53,0.1));
  border: 1px solid rgba(232,167,53,0.3); border-radius: 8px;
  font-weight: 900; font-size: 0.95rem; color: #f0b840;
}
.bone-tile {
  width: 28px; height: 14px;
  border: 1.5px solid rgba(160,150,120,0.35); border-radius: 4px;
  position: absolute;
  box-shadow: 0 1px 0 rgba(0,0,0,0.15), 0 2px 4px rgba(0,0,0,0.2),
    inset 0 1px 0 rgba(255,255,255,0.6);
}
.bone-tile::after {
  content: '◆'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 5px; color: rgba(160,140,100,0.15); font-weight: 900;
}

/* End sum */
#end-sum-display {
  position: fixed; top: 10px; right: 14px; padding: 10px 16px;
  background: linear-gradient(145deg, rgba(0,0,0,0.8), rgba(0,0,0,0.6));
  backdrop-filter: blur(12px);
  border-radius: 14px; font-size: 0.8rem; z-index: 10; text-align: center;
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  display: flex; gap: 14px; align-items: center;
}
#end-sum-left { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 70px; }
#end-sum-left .turn-avatar { width: 56px; height: 56px; border-radius: 50%; border: 3px solid rgba(232,167,53,0.5); }
#end-sum-left .turn-name { font-weight: 700; font-size: 0.8rem; color: #f0b840; text-align: center; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#end-sum-right { text-align: center; }
#end-sum-display .sum-value { font-size: 1.6rem; font-weight: 900; background: linear-gradient(180deg, #ffe080, #f0b840); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
#end-sum-display .sum-label { opacity: 0.35; font-size: 0.55rem; text-transform: uppercase; letter-spacing: 2px; font-weight: 700; }

/* Bottom bar */
#bottom-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 3;
  display: flex; flex-direction: column;
  background: none;
  pointer-events: none;
}
#bottom-bar > * { pointer-events: auto; }
.btn-draw, .btn-pass { padding: 10px 24px; border: none; border-radius: 10px; font-weight: 700; cursor: pointer; font-size: 0.9rem; transition: all 0.2s; letter-spacing: 0.5px; position: relative; overflow: hidden; }
.btn-draw { background: linear-gradient(145deg, #4aaf6c, #2d8a4e); color: #fff; box-shadow: 0 4px 14px rgba(45,138,78,0.35); }
.btn-draw:disabled { opacity: 0.3; cursor: not-allowed; box-shadow: none; }
.btn-draw:not(:disabled):hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 6px 20px rgba(45,138,78,0.45); }
.btn-pass { background: linear-gradient(145deg, #e04a3a, #b83025); color: #fff; box-shadow: 0 4px 14px rgba(192,57,43,0.35); }
.btn-pass:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 6px 20px rgba(192,57,43,0.45); }
.btn-hint { padding: 10px 20px; border: none; border-radius: 10px; font-weight: 700; cursor: pointer; font-size: 0.9rem; transition: all 0.2s; letter-spacing: 0.5px; background: linear-gradient(145deg, #7b5ea7, #5a3d8a); color: #fff; box-shadow: 0 4px 14px rgba(90,61,138,0.35); }
.btn-hint:disabled { opacity: 0.3; cursor: not-allowed; box-shadow: none; }
.btn-hint:not(:disabled):hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 6px 20px rgba(90,61,138,0.5); }

.hand-tile.hint-glow {
  animation: hintPulse 1s ease-in-out infinite; border: 3px solid #a855f7;
  box-shadow: 0 0 24px rgba(168,85,247,0.6), 0 0 48px rgba(168,85,247,0.2), 0 2px 0 #8040c0, 0 4px 0 #7030b0, 0 6px 14px rgba(0,0,0,0.3);
}
@keyframes hintPulse {
  0%,100% { box-shadow: 0 0 24px rgba(168,85,247,0.6), 0 0 48px rgba(168,85,247,0.2), 0 2px 0 #8040c0, 0 4px 0 #7030b0, 0 6px 14px rgba(0,0,0,0.3); }
  50% { box-shadow: 0 0 36px rgba(168,85,247,0.8), 0 0 72px rgba(168,85,247,0.3), 0 2px 0 #8040c0, 0 4px 0 #7030b0, 0 6px 14px rgba(0,0,0,0.3); }
}

/* 11. Card entrance animation */
#player-hand { display: flex; justify-content: center; gap: 10px; padding: 0 24px; flex-wrap: wrap; overflow-y: visible; max-height: 150px; min-height: 80px; position: relative; z-index: 6; margin-bottom: -46px; pointer-events: none; }
.hand-tile { pointer-events: auto; touch-action: manipulation; }

/* 3/4/5/6/18. 3D Hand Tiles with gloss, perspective tilt, playable pulse */
.hand-tile {
  width: 66px; height: 132px;
  background: linear-gradient(160deg, #fffef8 0%, #f5f0dc 30%, #e8e0c4 70%, #ddd5b5 100%);
  border: none; border-radius: 11px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: space-around;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s;
  position: relative;
  box-shadow: 0 2px 0 #c8c0a0, 0 4px 0 #b8b090, 0 6px 0 #a8a080, 0 8px 0 #989070,
    0 10px 20px rgba(0,0,0,0.4), inset 0 2px 0 rgba(255,255,255,0.9);
  animation: tileEntrance 0.4s ease-out backwards;
}
/* 4. Glossy reflection */
.hand-tile::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 45%;
  background: linear-gradient(180deg, rgba(255,255,255,0.15), transparent);
  border-radius: 11px 11px 0 0; pointer-events: none;
}
@keyframes tileEntrance { from { opacity: 0; transform: translateY(20px) scale(0.9); } }
/* 5. Hover with perspective tilt — --tiltX/--tiltY follow the cursor (set in JS) */
.hand-tile:hover {
  transform: translateY(-16px) scale(1.06) perspective(500px) rotateX(var(--tiltX, 3deg)) rotateY(var(--tiltY, 0deg));
  box-shadow: 0 2px 0 #c8c0a0, 0 4px 0 #b8b090, 0 6px 0 #a8a080, 0 8px 0 #989070,
    0 18px 35px rgba(0,0,0,0.5), inset 0 2px 0 rgba(255,255,255,0.9);
}
.hand-tile.selected {
  transform: translateY(-20px) scale(1.08);
  box-shadow: 0 2px 0 #d4a020, 0 4px 0 #c89018, 0 6px 0 #b88010, 0 8px 0 #a87008,
    0 20px 40px rgba(232,167,53,0.45), 0 0 30px rgba(232,167,53,0.3), inset 0 2px 0 rgba(255,255,255,0.9);
}
/* 6. Playable green pulse */
.hand-tile.playable {
  box-shadow: 0 2px 0 #3a9a5a, 0 4px 0 #2a8a4a, 0 6px 0 #1a7a3a, 0 8px 0 #0a6a2a,
    0 10px 20px rgba(0,0,0,0.4), 0 0 18px rgba(74,175,108,0.25), inset 0 2px 0 rgba(255,255,255,0.9);
  animation: tileEntrance 0.4s ease-out backwards, playablePulse 2s ease-in-out infinite;
}
@keyframes playablePulse { 0%,100% { box-shadow: 0 2px 0 #3a9a5a, 0 4px 0 #2a8a4a, 0 6px 0 #1a7a3a, 0 8px 0 #0a6a2a, 0 10px 20px rgba(0,0,0,0.4), 0 0 18px rgba(74,175,108,0.25), inset 0 2px 0 rgba(255,255,255,0.9); } 50% { box-shadow: 0 2px 0 #3a9a5a, 0 4px 0 #2a8a4a, 0 6px 0 #1a7a3a, 0 8px 0 #0a6a2a, 0 10px 20px rgba(0,0,0,0.4), 0 0 28px rgba(74,175,108,0.4), inset 0 2px 0 rgba(255,255,255,0.9); } }
.hand-tile.not-playable { opacity: 0.35; cursor: not-allowed; filter: saturate(0.2) brightness(0.9); box-shadow: 0 1px 0 #aaa, 0 2px 0 #999, 0 3px 8px rgba(0,0,0,0.2); }
.hand-tile .half { flex: 1; display: flex; align-items: center; justify-content: center; width: 100%; }
.hand-tile .divider { width: 78%; height: 2px; background: linear-gradient(90deg, transparent, #b0a880, #908060, #b0a880, transparent); border-radius: 1px; }

/* Turn toast notification — left justified near bottom */
#turn-indicator {
  position: fixed; bottom: 160px; left: 16px;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 24px 10px 14px;
  background: linear-gradient(145deg, rgba(20,20,20,0.9), rgba(10,10,10,0.95));
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  z-index: 10; pointer-events: none;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#turn-indicator.visible {
  opacity: 1;
  transform: translateY(0);
}
#turn-indicator.fading {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s ease-in, transform 0.5s ease-in;
}
#turn-indicator .toast-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid rgba(232,167,53,0.4);
  flex-shrink: 0;
}
#turn-indicator .toast-text {
  font-weight: 700; font-size: 0.95rem; color: #fff; white-space: nowrap;
}
#turn-indicator .toast-text span {
  color: #f0b840;
}

/* 20. Message overlay with blur + scale entrance */
#message-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.75); display: flex; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(8px); }
#message-overlay.hidden { display: none; }
.message-box {
  background: linear-gradient(145deg, #2a2a2a, #181818); padding: 40px 48px;
  border-radius: 24px; text-align: center; max-width: 440px;
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 30px 80px rgba(0,0,0,0.7), 0 0 40px rgba(232,167,53,0.05);
  animation: msgEntrance 0.3s ease-out;
}
@keyframes msgEntrance { from { opacity: 0; transform: scale(0.9) translateY(20px); } }
.message-box p { margin-bottom: 24px; font-size: 1.1rem; line-height: 1.7; opacity: 0.9; }

/* 21. Game over */
#gameover-screen { align-items: center; justify-content: center; }
#final-scores { margin: 24px 0; text-align: left; }
.final-score-row { display: flex; justify-content: space-between; align-items: center; padding: 16px 28px; margin: 8px 0; background: rgba(255,255,255,0.05); border-radius: 14px; min-width: 360px; border: 1px solid rgba(255,255,255,0.04); font-size: 1.1rem; transition: all 0.3s; }
.final-score-row.winner {
  background: linear-gradient(145deg, rgba(232,167,53,0.2), rgba(232,167,53,0.08));
  border: 2px solid rgba(232,167,53,0.4);
  box-shadow: 0 0 30px rgba(232,167,53,0.15), 0 0 60px rgba(232,167,53,0.05);
}

.btn-menu { position: fixed; top: 10px; left: 10px; background: linear-gradient(145deg, rgba(0,0,0,0.5), rgba(0,0,0,0.3)); border: 1px solid rgba(255,255,255,0.08); color: #fff; font-size: 1.4rem; width: 46px; height: 46px; border-radius: 12px; cursor: pointer; z-index: 12; display: flex; align-items: center; justify-content: center; transition: all 0.25s; backdrop-filter: blur(8px); }
.btn-menu:hover { background: rgba(0,0,0,0.6); border-color: rgba(255,255,255,0.15); transform: scale(1.08); }

/* Dropdown menu */
#game-dropdown {
  position: fixed; top: 62px; left: 10px; z-index: 12;
  background: linear-gradient(145deg, rgba(20,20,20,0.95), rgba(10,10,10,0.98));
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px; padding: 6px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  min-width: 220px;
  animation: ddIn 0.2s ease-out;
}
#game-dropdown.hidden { display: none; }
@keyframes ddIn { from { opacity: 0; transform: translateY(-8px) scale(0.95); } }
.dd-item {
  display: block; width: 100%; padding: 12px 16px;
  background: none; border: none; color: #fff;
  font-size: 0.95rem; font-weight: 600; text-align: left;
  cursor: pointer; border-radius: 10px; transition: all 0.15s;
}
.dd-item:hover { background: rgba(255,255,255,0.08); }
.dd-danger { color: #ff5a4a; }
.dd-danger:hover { background: rgba(255,80,60,0.12); }

/* In-game menu + rules overlays */
#game-menu-overlay, #rules-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); display: flex; align-items: center; justify-content: center; z-index: 200; backdrop-filter: blur(10px); }
#game-menu-overlay.hidden, #rules-overlay.hidden { display: none; }
.game-menu-panel { background: linear-gradient(145deg, #252525, #151515); padding: 44px 52px; border-radius: 28px; text-align: center; min-width: 340px; border: 1px solid rgba(255,255,255,0.06); box-shadow: 0 30px 100px rgba(0,0,0,0.8); animation: msgEntrance 0.3s ease-out; }
.game-menu-panel h2 { font-size: 2rem; margin-bottom: 32px; letter-spacing: 3px; background: linear-gradient(180deg, #fff 20%, #f0b840); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.gm-btn { display: block; width: 100%; padding: 18px 28px; margin: 12px 0; background: rgba(255,255,255,0.06); border: 1.5px solid rgba(255,255,255,0.08); color: #fff; border-radius: 14px; font-size: 1.1rem; font-weight: 700; cursor: pointer; transition: all 0.25s; text-align: left; letter-spacing: 0.5px; }
.gm-btn:hover { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.15); transform: translateX(6px); }
.gm-btn-danger { color: #ff6b5a; border-color: rgba(255,100,80,0.15); }
.gm-btn-danger:hover { background: rgba(255,80,60,0.1); border-color: rgba(255,100,80,0.3); }
.rules-panel { background: linear-gradient(145deg, #252525, #151515); padding: 40px 48px; border-radius: 28px; max-width: 620px; max-height: 85vh; overflow-y: auto; border: 1px solid rgba(255,255,255,0.06); box-shadow: 0 30px 100px rgba(0,0,0,0.8); animation: msgEntrance 0.3s ease-out; }
.rules-panel h2 { font-size: 1.8rem; margin-bottom: 24px; text-align: center; letter-spacing: 3px; background: linear-gradient(180deg, #fff 20%, #f0b840); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.rules-content { text-align: left; line-height: 1.8; }
.rules-content h3 { color: #f0b840; font-size: 0.95rem; margin-top: 20px; margin-bottom: 8px; letter-spacing: 2px; text-transform: uppercase; font-weight: 800; }
.rules-content p { font-size: 0.9rem; opacity: 0.8; margin-bottom: 10px; }
.rules-content strong { color: #f0b840; font-weight: 700; }
.rules-panel .gm-btn { margin-top: 24px; text-align: center; }

/* Score popup */
.score-popup { position: fixed; pointer-events: none; z-index: 50; font-size: 4.5rem; font-weight: 900; letter-spacing: 3px; color: #fff; text-shadow: 0 0 15px #f0b840, 0 0 30px #f0b840, 0 0 60px rgba(232,167,53,0.5), 0 6px 12px rgba(0,0,0,0.7), 3px 3px 0 #a06000; animation: scoreBlast 2.5s ease-out forwards; }
.score-popup .score-label { display: block; font-size: 1.3rem; letter-spacing: 5px; text-transform: uppercase; opacity: 0.85; text-shadow: 0 2px 6px rgba(0,0,0,0.6); }
/* Score ring burst — expands outward behind the number */
.score-popup::before {
  content: ''; position: absolute; top: 50%; left: 50%;
  width: 20px; height: 20px; border-radius: 50%;
  border: 3px solid rgba(232,167,53,0.6);
  transform: translate(-50%, -50%) scale(0);
  animation: scoreRing 0.8s ease-out 0.1s forwards;
  pointer-events: none;
}
.score-popup::after {
  content: ''; position: absolute; top: 50%; left: 50%;
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  transform: translate(-50%, -50%) scale(0);
  animation: scoreRing 0.6s ease-out 0.25s forwards;
  pointer-events: none;
}
@keyframes scoreRing {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(15); opacity: 0; }
}
@keyframes scoreBlast { 0% { opacity: 0; transform: translate(-50%,-50%) scale(0.2) rotate(-8deg); } 12% { opacity: 1; transform: translate(-50%,-50%) scale(1.5) rotate(3deg); } 22% { transform: translate(-50%,-50%) scale(0.95) rotate(-1deg); } 30% { transform: translate(-50%,-50%) scale(1.05) rotate(0); } 75% { opacity: 1; transform: translate(-50%,-50%) scale(1) translateY(-20px); } 100% { opacity: 0; transform: translate(-50%,-50%) scale(1.3) translateY(-90px); } }
@keyframes scoreFlash { 0% { background: rgba(232,167,53,0.5); transform: scale(1.06); } 100% { background: transparent; transform: scale(1); } }
.score-item.score-flash { animation: scoreFlash 0.8s ease-out; }

/* Score vignette flash — golden edge pulse on scoring */
.score-vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 49;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(232,167,53,0.3) 100%);
  animation: vignetteFlash 0.6s ease-out forwards;
}
.score-vignette.big {
  background: radial-gradient(ellipse at center, transparent 40%, rgba(232,167,53,0.5) 100%);
  animation: vignetteFlash 0.8s ease-out forwards;
}
@keyframes vignetteFlash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* Floating turn arrow */
#floating-arrow { position: fixed; z-index: 8; pointer-events: none; width: 180px; height: 180px; opacity: 0.45; transition: top 0.6s cubic-bezier(0.34,1.56,0.64,1), left 0.6s cubic-bezier(0.34,1.56,0.64,1), transform 0.6s cubic-bezier(0.34,1.56,0.64,1); filter: drop-shadow(0 0 10px rgba(232,167,53,0.4)); }
#floating-arrow::after { content: ''; display: block; width: 0; height: 0; border-left: 90px solid transparent; border-right: 90px solid transparent; border-top: 150px solid #f0b840; animation: arrowBob 0.8s ease-in-out infinite; }
@keyframes arrowBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(10px); } }
#floating-arrow.point-up::after { border-top: none; border-bottom: 150px solid #f0b840; animation: arrowBobUp 0.8s ease-in-out infinite; }
@keyframes arrowBobUp { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
#floating-arrow.point-left::after { border-left: none; border-right: none; border-top: none; border-bottom: none; border-top: 90px solid transparent; border-bottom: 90px solid transparent; border-right: 150px solid #f0b840; animation: arrowBobLeft 0.8s ease-in-out infinite; }
@keyframes arrowBobLeft { 0%,100% { transform: translateX(0); } 50% { transform: translateX(-10px); } }
#floating-arrow.point-right::after { border-left: none; border-right: none; border-top: none; border-bottom: none; border-top: 90px solid transparent; border-bottom: 90px solid transparent; border-left: 150px solid #f0b840; animation: arrowBobRight 0.8s ease-in-out infinite; }
@keyframes arrowBobRight { 0%,100% { transform: translateX(0); } 50% { transform: translateX(10px); } }
.turn-arrow { display: none; }
.score-item .turn-arrow-sb { display: none; }

/* Hidden scoreboard */
#scoreboard { display: none; }

/* Bone counting overlay */
#count-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.8);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 90; backdrop-filter: blur(6px);
}
#count-overlay.hidden { display: none; }
.count-title {
  font-size: 1.6rem; font-weight: 900; margin-bottom: 24px; letter-spacing: 2px;
  background: linear-gradient(180deg, #fff 20%, #f0b840);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.count-player {
  display: flex; align-items: center; gap: 16px;
  margin: 10px 0; padding: 14px 24px; border-radius: 14px;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.06);
  min-width: 360px; transition: all 0.4s;
}
.count-player .count-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2); flex-shrink: 0;
}
.count-player .count-info { flex: 1; }
.count-player .count-name { font-weight: 700; font-size: 1rem; }
.count-tiles {
  display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap;
}
.count-tile {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  width: 32px; height: 60px; border-radius: 6px;
  background: linear-gradient(160deg, #fffef8, #e8e0c4);
  border: 1.5px solid rgba(180,170,140,0.5);
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  font-size: 0.7rem; font-weight: 800; color: #333;
  opacity: 0; transform: rotateY(90deg);
  animation: tileFlip 0.4s ease-out forwards;
}
.count-tile .ct-half { flex: 1; display: flex; align-items: center; justify-content: center; }
.count-tile .ct-div { width: 60%; height: 1px; background: #bbb; }
@keyframes tileFlip {
  0% { opacity: 0; transform: rotateY(90deg) scale(0.8); }
  100% { opacity: 1; transform: rotateY(0) scale(1); }
}
.count-pips {
  font-weight: 900; font-size: 1.4rem; color: #f0b840; min-width: 40px; text-align: right;
  text-shadow: 0 0 8px rgba(232,167,53,0.3);
}
.count-total {
  margin-top: 20px; font-size: 1.3rem; font-weight: 800;
  padding: 12px 28px; border-radius: 12px;
  background: rgba(232,167,53,0.15); border: 1px solid rgba(232,167,53,0.3);
  opacity: 0; animation: countFadeIn 0.5s ease-out forwards;
}
.count-total .ct-bonus {
  font-size: 1.8rem; font-weight: 900;
  background: linear-gradient(180deg, #ffe080, #f0b840);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
@keyframes countFadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Responsive adjustments */
@media (max-width: 900px) {
  .opponent-hand.left, .opponent-hand.right { width: 64px; padding: 4px 3px; }
  .opp-avatar { width: 36px; height: 36px; }
  .opp-name { font-size: 0.7rem; }
  .opp-score { font-size: 1rem; }
  .opp-record { font-size: 0.55rem; }
  .face-down { width: 22px; height: 11px; border-radius: 3px; }
  .face-down.vertical { width: 11px; height: 22px; }
  .face-down::before { font-size: 3px; }
  .hand-tile { width: 52px; height: 104px; border-radius: 8px; }
  #human-info .human-avatar { width: 32px; height: 32px; }
  #human-info .human-score { font-size: 1.1rem; }
  #human-info .human-name { font-size: 0.8rem; }
  .btn-draw, .btn-pass, .btn-hint { padding: 6px 14px; font-size: 0.75rem; }
  #boneyard-tiles { width: 100px; height: 28px; }
  .bone-tile { width: 22px; height: 11px; }
  #floating-arrow { width: 40px; height: 40px; }
  #floating-arrow::after { border-left-width: 20px; border-right-width: 20px; border-top-width: 34px; }
  #floating-arrow.point-up::after { border-bottom-width: 34px; }
  #floating-arrow.point-left::after { border-top-width: 20px; border-bottom-width: 20px; border-right-width: 34px; }
  #floating-arrow.point-right::after { border-top-width: 20px; border-bottom-width: 20px; border-left-width: 34px; }
  .score-popup { font-size: 2.5rem; }
  .score-popup .score-label { font-size: 0.9rem; }
  .think-card .think-avatar { width: 40px; height: 40px; }
  .think-card .think-name { font-size: 0.95rem; }
  .sb-team-score, .sb-ps-score { font-size: 1.1rem; }
  #score-bar { gap: 8px; padding: 6px 10px; }
  .sb-team, .sb-player-score { padding: 4px 10px; }
}

@media (max-width: 600px) {
  .opponent-hand.left, .opponent-hand.right { width: 48px; padding: 2px 2px; }
  .opponent-hand.top { min-height: 50px; padding: 4px 8px; }
  .opp-avatar { width: 28px; height: 28px; }
  .opp-name { font-size: 0.6rem; }
  .opp-score { font-size: 0.85rem; }
  .face-down { width: 18px; height: 9px; }
  .face-down.vertical { width: 9px; height: 18px; }
  .face-down::before { display: none; }
  .hand-tile { width: 42px; height: 84px; border-radius: 6px; }
  .hand-tile .half svg { width: 32px; height: 32px; }
  #player-hand { gap: 5px; padding: 6px 10px 10px; max-height: 120px; min-height: 70px; }
  #human-info { gap: 8px; padding: 4px 8px; }
  #human-info .human-avatar { width: 28px; height: 28px; }
  #human-info .human-score { font-size: 0.9rem; }
  .btn-draw, .btn-pass, .btn-hint { padding: 5px 10px; font-size: 0.7rem; border-radius: 6px; }
  #boneyard-area { min-height: 36px; padding: 4px 8px; }
  #boneyard-tiles { width: 70px; height: 22px; }
  .bone-tile { width: 16px; height: 8px; }
  #floating-arrow { width: 30px; height: 30px; }
  #floating-arrow::after { border-left-width: 15px; border-right-width: 15px; border-top-width: 25px; }
  #floating-arrow.point-up::after { border-bottom-width: 25px; }
  #floating-arrow.point-left::after { border-top-width: 15px; border-bottom-width: 15px; border-right-width: 25px; }
  #floating-arrow.point-right::after { border-top-width: 15px; border-bottom-width: 15px; border-left-width: 25px; }
  .menu-container { padding: 24px 28px; }
  .game-title { font-size: 2.2rem; letter-spacing: 5px; }
  .title-tile { width: 36px; height: 64px; }
  .subtitle { letter-spacing: 8px; font-size: 1rem; }
  .roster-card .roster-avatar { width: 40px; height: 40px; }
  #score-bar { gap: 6px; padding: 4px 8px; font-size: 0.8rem; }
  .sb-team-score, .sb-ps-score { font-size: 0.95rem; }
  #end-sum-display { top: 50px; right: 8px; padding: 6px 10px; gap: 8px; }
  #end-sum-display .sum-value { font-size: 1.1rem; }
  #end-sum-left .turn-avatar { width: 28px; height: 28px; }
  #end-sum-left .turn-name { font-size: 0.6rem; max-width: 55px; }
  #end-sum-left { min-width: 40px; }
  #end-sum-breakdown { font-size: 0.65rem; }
  #end-sum-score { font-size: 0.6rem; }
  .think-card { padding: 12px 20px; gap: 10px; }
  .think-card .think-avatar { width: 36px; height: 36px; }
  .think-card .think-name { font-size: 0.85rem; }
}

@media (max-height: 600px) {
  .opponent-hand.top { min-height: 44px; padding: 3px 8px; }
  .opp-avatar { width: 28px; height: 28px; }
  #player-hand { max-height: 100px; min-height: 60px; padding: 4px 10px; }
  .hand-tile { width: 44px; height: 88px; }
  #boneyard-area { min-height: 30px; padding: 3px 8px; }
  #human-info { padding: 3px 10px; }
  #score-bar { padding: 4px 10px; }
}

/* Old floating buttons removed — now in score bar */

#log-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; backdrop-filter: blur(10px);
}
#log-overlay.hidden { display: none; }
.log-panel {
  background: linear-gradient(145deg, #252525, #151515);
  padding: 32px 36px; border-radius: 24px;
  max-width: 500px; width: 90%; max-height: 80vh;
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 30px 100px rgba(0,0,0,0.8);
  animation: msgEntrance 0.3s ease-out;
  display: flex; flex-direction: column;
}
.log-panel h2 {
  font-size: 1.4rem; margin-bottom: 16px; text-align: center; letter-spacing: 2px; flex-shrink: 0;
  background: linear-gradient(180deg, #fff 20%, #f0b840);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
#log-entries {
  flex: 1; overflow-y: auto; margin-bottom: 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.log-entry {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 10px;
  background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.03);
  font-size: 0.85rem; line-height: 1.3;
}
.log-entry .log-num {
  font-size: 0.7rem; opacity: 0.3; font-weight: 700; min-width: 24px; text-align: right;
  font-family: 'Inter', monospace;
}
.log-entry .log-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.15); flex-shrink: 0;
}
.log-entry .log-name { font-weight: 700; color: #f0b840; }
.log-entry .log-tile {
  display: inline-flex; align-items: center; gap: 0;
  padding: 3px 4px; border-radius: 5px;
  background: linear-gradient(160deg, #f5f0dc, #e0d8b8);
  border: 1.5px solid rgba(180,170,140,0.5);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  vertical-align: middle;
}
.log-tile-half {
  display: flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; position: relative;
}
.log-tile-div {
  width: 1px; height: 14px; background: rgba(0,0,0,0.15); margin: 0 1px;
}
.log-pip {
  width: 3.5px; height: 3.5px; border-radius: 50%;
  background: #333; position: absolute;
}
.log-entry .log-score { color: #4aaf6c; font-weight: 800; }
.log-entry .log-action { opacity: 0.6; }
.log-entry.log-score-entry { background: rgba(232,167,53,0.06); border-color: rgba(232,167,53,0.1); }
.log-entry.log-draw-entry { background: rgba(74,175,108,0.04); }

.log-entry.log-round-end {
  background: linear-gradient(145deg, rgba(232,167,53,0.1), rgba(232,167,53,0.04));
  border: 1px solid rgba(232,167,53,0.15);
  padding: 12px 14px;
}

/* Shortcuts — now in score bar */

#shortcuts-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; backdrop-filter: blur(10px);
}
#shortcuts-overlay.hidden { display: none; }
.shortcuts-panel {
  background: linear-gradient(145deg, #252525, #151515);
  padding: 32px 40px; border-radius: 24px;
  max-width: 420px; width: 90%;
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 30px 100px rgba(0,0,0,0.8);
  animation: msgEntrance 0.3s ease-out;
}
.shortcuts-panel h2 {
  font-size: 1.4rem; margin-bottom: 20px; text-align: center; letter-spacing: 2px;
  background: linear-gradient(180deg, #fff 20%, #f0b840);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.shortcut-grid { display: flex; flex-direction: column; gap: 6px; }
.sc-row {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.9rem;
}
.sc-row kbd {
  display: inline-block; min-width: 28px; padding: 3px 8px; text-align: center;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px; font-family: 'Inter', monospace; font-weight: 700;
  font-size: 0.8rem; color: #f0b840;
}
.sc-row span { opacity: 0.7; }

/* Speech bubble */
.speech-bubble {
  position: fixed; z-index: 20; pointer-events: none;
  max-width: 220px; padding: 12px 18px;
  background: linear-gradient(145deg, rgba(20,20,20,0.92), rgba(10,10,10,0.95));
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px; border-bottom-left-radius: 4px;
  color: #fff; font-size: 1.1rem; font-weight: 700; line-height: 1.3;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  animation: bubbleIn 0.3s ease-out, bubbleOut 0.5s ease-in 2s forwards;
}
@keyframes bubbleIn { from { opacity: 0; transform: scale(0.7) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes bubbleOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }

/* Countdown overlay */
#countdown-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 150; pointer-events: none;
  background: rgba(0,0,0,0.4);
}
#countdown-overlay.hidden { display: none; }
.countdown-num {
  font-size: 10rem; font-weight: 900; color: #fff;
  text-shadow: 0 0 30px #f0b840, 0 0 60px rgba(232,167,53,0.4), 0 8px 16px rgba(0,0,0,0.6);
  animation: countPop 0.8s ease-out forwards;
}
.countdown-go {
  font-size: 5rem; font-weight: 900; letter-spacing: 8px;
  background: linear-gradient(180deg, #fff 20%, #f0b840);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  text-shadow: none;
  filter: drop-shadow(0 0 20px rgba(232,167,53,0.5)) drop-shadow(0 4px 8px rgba(0,0,0,0.5));
  animation: countPop 0.6s ease-out forwards;
}
@keyframes countPop {
  0% { opacity: 0; transform: scale(2.5); }
  30% { opacity: 1; transform: scale(0.9); }
  50% { transform: scale(1.05); }
  100% { opacity: 0; transform: scale(0.8); }
}

/* Draw button bounce when active */
.btn-draw.needs-draw {
  animation: drawBounce 1s ease-in-out infinite;
}
@keyframes drawBounce {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
  50% { transform: translateY(0); }
  70% { transform: translateY(-3px); }
}

/* Score stars */
.score-stars {
  position: fixed; left: 50%; top: 55%;
  transform: translateX(-50%);
  display: flex; gap: 8px; z-index: 51; pointer-events: none;
}
.score-star {
  font-size: 3rem;
  opacity: 0;
  filter: drop-shadow(0 0 12px rgba(232,167,53,0.7)) drop-shadow(0 0 24px rgba(232,167,53,0.3));
  animation: starPop 0.4s ease-out forwards, starGlow 1.5s ease-in-out 0.4s infinite, starFadeOut 0.5s ease-in 2s forwards;
}
@keyframes starPop {
  0% { opacity: 0; transform: scale(0) rotate(-30deg); }
  60% { opacity: 1; transform: scale(1.3) rotate(10deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}
@keyframes starGlow {
  0%, 100% { filter: drop-shadow(0 0 12px rgba(232,167,53,0.7)) drop-shadow(0 0 24px rgba(232,167,53,0.3)); }
  50% { filter: drop-shadow(0 0 20px rgba(232,167,53,0.9)) drop-shadow(0 0 40px rgba(232,167,53,0.5)); }
}
@keyframes starFadeOut {
  to { opacity: 0; transform: translateY(-20px) scale(0.8); }
}

/* Hover-active hand tile */
.hand-tile.hover-active {
  transform: translateY(-10px) scale(1.03);
  box-shadow: 0 2px 0 #c8c0a0, 0 4px 0 #b8b090, 0 6px 0 #a8a080, 0 8px 0 #989070,
    0 12px 25px rgba(0,0,0,0.45), 0 0 20px rgba(232,167,53,0.2), inset 0 2px 0 rgba(255,255,255,0.9);
  border: 2px solid rgba(232,167,53,0.4);
}

/* Round announcement — cinematic staggered entrance */
@keyframes announceIn {
  0% { opacity: 0; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1); }
}

/* Round announcement components */
.ra-container {
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 0;
}
.ra-label {
  font-size: 1.2rem; font-weight: 700; letter-spacing: 12px;
  color: rgba(255,255,255,0.4); text-transform: uppercase;
  opacity: 0; animation: raSlideDown 0.5s ease-out 0.1s forwards;
}
.ra-number {
  font-size: 10rem; font-weight: 900; line-height: 1;
  background: linear-gradient(180deg, #fff 10%, #f0b840 40%, #c09830 70%, #8a6a20);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  filter: drop-shadow(0 0 40px rgba(232,167,53,0.5));
  opacity: 0; animation: raNumberPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s forwards;
}
.ra-divider {
  width: 120px; height: 2px; margin: 12px 0 20px;
  background: linear-gradient(90deg, transparent, #f0b840, transparent);
  opacity: 0; animation: raFadeIn 0.4s ease-out 0.7s forwards;
}
.ra-player {
  display: flex; align-items: center; justify-content: center; gap: 20px;
  opacity: 0; animation: raSlideUp 0.5s ease-out 0.8s forwards;
}
.ra-avatar {
  width: 80px; height: 80px; border-radius: 50%;
  border: 3px solid rgba(232,167,53,0.6);
  box-shadow: 0 4px 24px rgba(0,0,0,0.5), 0 0 24px rgba(232,167,53,0.25);
}
.ra-tile {
  filter: drop-shadow(0 6px 20px rgba(0,0,0,0.6)) drop-shadow(0 0 20px rgba(232,167,53,0.3));
  animation: raTileSpin 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) 1s both;
}
.ra-who {
  font-size: 1.3rem; font-weight: 700; color: rgba(255,255,255,0.85);
  margin-top: 16px;
  opacity: 0; animation: raFadeIn 0.4s ease-out 1.2s forwards;
}

@keyframes raSlideDown {
  0% { opacity: 0; transform: translateY(-20px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes raNumberPop {
  0% { opacity: 0; transform: scale(0.3); }
  70% { opacity: 1; transform: scale(1.1); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes raSlideUp {
  0% { opacity: 0; transform: translateY(30px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes raFadeIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}
@keyframes raTileSpin {
  0% { opacity: 0; transform: rotateY(90deg) scale(0.5); }
  100% { opacity: 1; transform: rotateY(0) scale(1); }
}

/* Stats dashboard */
#stats-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); display: flex; align-items: center; justify-content: center; z-index: 200; backdrop-filter: blur(10px); }
#stats-overlay.hidden { display: none; }
.stats-panel { background: linear-gradient(145deg, #252525, #151515); padding: 32px 40px; border-radius: 24px; max-width: 480px; width: 90%; max-height: 80vh; overflow-y: auto; border: 1px solid rgba(255,255,255,0.06); box-shadow: 0 30px 100px rgba(0,0,0,0.8); animation: msgEntrance 0.3s ease-out; }
.stats-panel h2 { font-size: 1.4rem; margin-bottom: 20px; text-align: center; letter-spacing: 2px; background: linear-gradient(180deg, #fff 20%, #f0b840); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.stat-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.04); font-size: 0.9rem; }
.stat-label { opacity: 0.6; }
.stat-value { font-weight: 800; color: #f0b840; }
.stat-section { margin-top: 16px; }
.stat-section-title { font-size: 0.7rem; opacity: 0.35; text-transform: uppercase; letter-spacing: 2px; margin-bottom: 8px; }

/* Achievements */
.achievement-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.03); }
.achievement-icon { font-size: 1.5rem; width: 36px; text-align: center; }
.achievement-info { flex: 1; }
.achievement-name { font-weight: 700; font-size: 0.9rem; }
.achievement-desc { font-size: 0.75rem; opacity: 0.4; }
.achievement-row.locked { opacity: 0.3; filter: grayscale(1); }
.achievement-row.unlocked .achievement-name { color: #f0b840; }

/* Achievement unlock popup */
.achievement-popup { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: linear-gradient(145deg, rgba(20,20,20,0.95), rgba(10,10,10,0.98)); backdrop-filter: blur(12px); border: 1px solid rgba(232,167,53,0.3); border-radius: 14px; z-index: 60; pointer-events: none; box-shadow: 0 8px 30px rgba(0,0,0,0.5), 0 0 20px rgba(232,167,53,0.15); animation: achIn 0.4s ease-out, achOut 0.5s ease-in 3s forwards; }
.achievement-popup .ach-icon { font-size: 2rem; }
.achievement-popup .ach-text { font-weight: 700; color: #f0b840; }
.achievement-popup .ach-label { font-size: 0.7rem; opacity: 0.5; text-transform: uppercase; letter-spacing: 1px; }
@keyframes achIn { from { opacity: 0; transform: translateX(-50%) translateY(20px); } }
@keyframes achOut { to { opacity: 0; transform: translateX(-50%) translateY(20px); } }

/* Particles */
.particle { position: fixed; pointer-events: none; z-index: 55; border-radius: 50%; }
.particle-gold { background: #f0b840; box-shadow: 0 0 6px #f0b840; animation: particleFly 1s ease-out forwards; }
.particle-confetti { animation: confettiFall 2s ease-in forwards; }
@keyframes particleFly { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes confettiFall { 0% { opacity: 1; transform: translateY(0) rotate(0); } 100% { opacity: 0; transform: translateY(100vh) rotate(720deg); } }

/* Sound toggle */
.btn-sound { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08); color: #fff; font-size: 1rem; width: 36px; height: 36px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.btn-sound:hover { background: rgba(255,255,255,0.12); }
.btn-sound.muted { opacity: 0.4; }

/* Deal animation */
.deal-tile { position: fixed; z-index: 55; pointer-events: none; width: 30px; height: 15px; background: linear-gradient(160deg, #f5f0dc, #c8c0a0); border: 1.5px solid rgba(180,170,140,0.4); border-radius: 4px; box-shadow: 0 2px 6px rgba(0,0,0,0.3); transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }

/* Name edit */
.name-edit { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); color: #fff; padding: 6px 12px; border-radius: 8px; font-size: 1rem; font-weight: 700; font-family: 'Inter', sans-serif; width: 140px; text-align: center; outline: none; }
.name-edit:focus { border-color: rgba(232,167,53,0.5); box-shadow: 0 0 10px rgba(232,167,53,0.2); }

/* Preferences */
#prefs-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); display: flex; align-items: center; justify-content: center; z-index: 200; backdrop-filter: blur(10px); }
#prefs-overlay.hidden { display: none; }
.pref-group { margin-bottom: 22px; }
.pref-label { font-size: 0.7rem; opacity: 0.4; text-transform: uppercase; letter-spacing: 2px; margin-bottom: 10px; border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 6px; }
.skin-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.skin-option {
  padding: 12px 8px; border-radius: 10px; cursor: pointer;
  border: 2px solid rgba(255,255,255,0.08); transition: all 0.2s;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 600; gap: 8px;
  background: rgba(255,255,255,0.03);
}
.skin-option:hover { border-color: rgba(255,255,255,0.2); background: rgba(255,255,255,0.06); }
.skin-option.active { border-color: #f0b840; box-shadow: 0 0 16px rgba(232,167,53,0.25); background: rgba(232,167,53,0.08); }
.skin-preview { width: 48px; height: 24px; border-radius: 4px; border: 1.5px solid rgba(0,0,0,0.2); box-shadow: 0 2px 4px rgba(0,0,0,0.2); }

/* XP Bar — fancy game style */
#xp-bar-wrap { display: flex; align-items: center; gap: 8px; }
.xp-level {
  font-size: 0.7rem; font-weight: 900; min-width: 56px;
  padding: 3px 10px; border-radius: 6px; text-align: center;
  background: linear-gradient(145deg, #f0b840, #c07800);
  color: #1a1a1a; box-shadow: 0 2px 6px rgba(232,167,53,0.3);
  letter-spacing: 0.5px;
}
.xp-bar { width: 80px; height: 8px; background: rgba(255,255,255,0.08); border-radius: 4px; overflow: hidden; border: 1px solid rgba(255,255,255,0.06); }
.xp-fill { height: 100%; background: linear-gradient(90deg, #f0b840, #e08020, #f0b840); border-radius: 4px; transition: width 0.5s ease; background-size: 200% 100%; animation: xpShimmer 2s linear infinite; }
@keyframes xpShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Music indicator */
.music-toggle { display: flex; align-items: center; gap: 8px; padding: 8px 0; cursor: pointer; }
.music-toggle input { accent-color: #f0b840; }

/* AI personality badge */
.personality-badge { font-size: 0.55rem; opacity: 0.5; font-style: italic; }

/* Tutorial */
#tutorial-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.85); display: flex; align-items: center; justify-content: center; z-index: 250; backdrop-filter: blur(12px); }
#tutorial-overlay.hidden { display: none; }
.tutorial-panel { background: linear-gradient(145deg, #252525, #151515); padding: 36px 44px; border-radius: 28px; max-width: 560px; width: 92%; border: 1px solid rgba(255,255,255,0.06); box-shadow: 0 30px 100px rgba(0,0,0,0.8); animation: msgEntrance 0.3s ease-out; position: relative; }
.tut-title { font-size: 1.5rem; font-weight: 900; text-align: center; margin-bottom: 6px; background: linear-gradient(180deg, #fff 20%, #f0b840); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.tut-subtitle { font-size: 0.8rem; opacity: 0.4; text-align: center; margin-bottom: 20px; letter-spacing: 1px; }
.tut-body { font-size: 0.95rem; line-height: 1.7; opacity: 0.85; margin-bottom: 16px; }
.tut-body strong { color: #f0b840; font-weight: 700; }
.tut-visual { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 20px 0; flex-wrap: wrap; }
.tut-tile-svg { filter: drop-shadow(0 3px 8px rgba(0,0,0,0.4)); }
.tut-highlight { background: rgba(232,167,53,0.1); border: 1px solid rgba(232,167,53,0.2); border-radius: 12px; padding: 14px 18px; margin: 12px 0; }
.tut-score-example { font-size: 1.8rem; font-weight: 900; color: #f0b840; text-align: center; margin: 8px 0; }
.tut-plus { font-size: 1.5rem; opacity: 0.3; font-weight: 700; }
.tut-equals { font-size: 1.2rem; opacity: 0.5; font-weight: 700; }
.tutorial-nav { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,0.05); }
.tut-btn-prev, .tut-btn-next { padding: 10px 24px; border: none; border-radius: 10px; font-weight: 700; font-size: 0.9rem; cursor: pointer; transition: all 0.2s; }
.tut-btn-next { background: linear-gradient(145deg, #f0b840, #d4922a); color: #1a1a1a; box-shadow: 0 4px 12px rgba(232,167,53,0.3); }
.tut-btn-next:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(232,167,53,0.4); }
.tut-btn-prev { background: rgba(255,255,255,0.08); color: #fff; border: 1px solid rgba(255,255,255,0.1); }
.tut-btn-prev:hover { background: rgba(255,255,255,0.12); }
.tut-btn-prev:disabled, .tut-btn-next:disabled { opacity: 0.3; cursor: not-allowed; }
.tut-dots { display: flex; gap: 6px; }
.tut-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.15); transition: all 0.2s; }
.tut-dot.active { background: #f0b840; transform: scale(1.3); }

/* Toggle switch */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; }
.toggle-row span { font-size: 0.95rem; font-weight: 600; }
.toggle-switch { position: relative; width: 48px; height: 26px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: rgba(255,255,255,0.12); border-radius: 26px;
  transition: all 0.3s;
}
.toggle-slider::before {
  content: ''; position: absolute; left: 3px; top: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; transition: all 0.3s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.toggle-switch input:checked + .toggle-slider {
  background: linear-gradient(145deg, #f0b840, #d4922a);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

/* Tile tracker popup */
#tracker-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); display: flex; align-items: center; justify-content: center; z-index: 200; backdrop-filter: blur(10px); }
#tracker-overlay.hidden { display: none; }
.tracker-panel { background: linear-gradient(145deg, #252525, #151515); padding: 28px 32px; border-radius: 24px; max-width: 400px; width: 90%; border: 1px solid rgba(255,255,255,0.06); box-shadow: 0 30px 100px rgba(0,0,0,0.8); animation: msgEntrance 0.3s ease-out; }
.tracker-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.tracker-tile { width: 100%; aspect-ratio: 1/1.6; border-radius: 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 0.6rem; font-weight: 700; border: 1px solid rgba(255,255,255,0.1); }
.tracker-tile.played { background: rgba(232,167,53,0.2); border-color: rgba(232,167,53,0.3); opacity: 0.4; }
.tracker-tile.unplayed { background: rgba(255,255,255,0.06); }

/* Match count badge on hand tiles */
.match-badge { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; background: #f0b840; color: #1a1a1a; font-size: 0.65rem; font-weight: 900; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px rgba(0,0,0,0.3); z-index: 2; }

/* Table themes */
.table-green { --felt: #1e7a35; --felt-dark: #0d3a18; }
.table-blue { --felt: #1a4a7a; --felt-dark: #0a2a4a; }
.table-red { --felt: #7a1a2a; --felt-dark: #3a0a14; }
.table-purple { --felt: #4a1a6a; --felt-dark: #2a0a3a; }
.table-wood { --felt: #6a4a2a; --felt-dark: #3a2a14; }

/* Post-game analysis */
.analysis-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.04); font-size: 0.9rem; }
.analysis-value { font-weight: 800; color: #f0b840; }

/* Active player avatar bounce on board */
.opp-label.active-turn .opp-avatar {
  animation: avatarPulse 2s ease-in-out infinite, avatarBounce 1.5s ease-in-out infinite;
}
@keyframes avatarBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* Rage quit overlay */
#ragequit-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); display: flex; align-items: center; justify-content: center; z-index: 210; backdrop-filter: blur(8px); }
#ragequit-overlay.hidden { display: none; }

/* Phone-specific (< 480px) */
@media (max-width: 480px) {
  .opponent-hand.left, .opponent-hand.right { width: 40px; padding: 2px 1px; }
  .opponent-hand.top { min-height: 40px; padding: 3px 6px; }
  .opp-avatar { width: 24px; height: 24px; border-width: 2px; }
  .opp-name { font-size: 0.55rem; }
  .opp-score { font-size: 0.75rem; }
  .opp-record { display: none; }
  .personality-badge { display: none; }
  .face-down { width: 14px; height: 7px; border-radius: 2px; }
  .face-down.vertical { width: 7px; height: 14px; }
  .face-down::before, .face-down::after { display: none; }
  .hand-tile { width: 46px; height: 92px; border-radius: 7px; }
  .hand-tile .half svg { width: 36px; height: 36px; }
  #player-hand { gap: 6px; padding: 8px 10px 6px; max-height: 130px; min-height: 80px; margin-bottom: -40px; }
  /* Wrap controls to a second row instead of clipping them behind a horizontal scroll */
  #human-info { gap: 6px; padding: 4px 8px; flex-wrap: wrap; overflow-x: visible; }
  #player-controls { margin-left: 0; width: 100%; justify-content: center; }
  #human-info .human-avatar { width: 24px; height: 24px; }
  #human-info .human-name { font-size: 0.65rem; }
  #human-info .human-score { font-size: 0.85rem; }
  #human-info .human-record { display: none; }
  .btn-draw, .btn-pass, .btn-hint { padding: 6px 10px; font-size: 0.7rem; border-radius: 7px; white-space: nowrap; }
  #boneyard-area { min-height: 24px; padding: 2px 4px; }
  #boneyard-tiles { width: 40px; height: 16px; }
  .bone-tile { width: 10px; height: 5px; }
  #boneyard-label { font-size: 0.6rem; }
  #floating-arrow { display: none; }
  .score-popup { font-size: 2rem; }
  .score-popup .score-label { font-size: 0.7rem; }

  /* Score bar — compact single row; inline-start padding clears the fixed menu button */
  #score-bar { gap: 4px; padding: 3px 6px; padding-inline-start: 48px; font-size: 0.7rem; }
  #score-bar-content { gap: 4px; }
  .sb-round { font-size: 0.85rem; }
  .sb-team-score, .sb-ps-score { font-size: 0.8rem; }
  .sb-team, .sb-player-score { padding: 2px 6px; border-radius: 6px; gap: 4px; }
  .sb-ps-name { max-width: 48px; font-size: 0.65rem; }
  .sb-team-name { max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.65rem; }
  .sb-target { font-size: 0.5rem; }
  .sb-vs { font-size: 0.6rem; }

  /* End sum — compact, hide the avatar/last-played section on phones */
  #end-sum-display { 
    padding: 4px 8px; top: auto; bottom: 170px; right: 4px; 
    gap: 4px; border-radius: 8px; font-size: 0.7rem;
    max-width: 120px;
  }
  #end-sum-display .sum-value { font-size: 0.9rem; }
  #end-sum-display .sum-label { font-size: 0.45rem; letter-spacing: 1px; }
  #end-sum-left { display: none; }
  #last-played-tile { display: none; }
  #end-sum-breakdown { font-size: 0.6rem; }
  #end-sum-score { font-size: 0.6rem; }

  .menu-container { padding: 20px 16px; border-radius: 16px; }
  .game-title { font-size: 1.8rem; letter-spacing: 3px; }
  .subtitle { font-size: 0.85rem; letter-spacing: 5px; margin-bottom: 16px; }
  .title-tile { width: 30px; height: 54px; }
  .title-wrap { gap: 12px; }
  .btn-option { padding: 8px 8px; font-size: 0.8rem; border-radius: 8px; }
  .btn-start { padding: 12px 32px; font-size: 1rem; }
  .roster-card .roster-avatar { width: 36px; height: 36px; }
  .roster-card { padding: 8px 10px; gap: 8px; }
  .roster-card .roster-name { font-size: 0.9rem; }
  .speech-bubble { max-width: 140px; font-size: 0.8rem; padding: 6px 10px; border-radius: 10px; }
  .think-card { padding: 6px 12px; gap: 6px; }
  .think-card .think-avatar { width: 24px; height: 24px; }
  .think-card .think-name { font-size: 0.7rem; }
  .btn-menu { width: 32px; height: 32px; font-size: 0.9rem; border-radius: 6px; }
  #game-dropdown { min-width: 160px; left: 6px; top: 44px; }
  .dd-item { padding: 8px 10px; font-size: 0.8rem; }
  .tutorial-panel { padding: 20px 16px; }
  .tut-title { font-size: 1.1rem; }
  .tut-body { font-size: 0.8rem; }
  .tut-btn-prev, .tut-btn-next { padding: 8px 16px; font-size: 0.8rem; }
  .rules-panel { padding: 20px 16px; }
  .rules-content h3 { font-size: 0.8rem; }
  .rules-content p { font-size: 0.75rem; }
  .count-player { padding: 6px 8px; gap: 6px; min-width: auto; }
  .count-avatar { width: 32px; height: 32px; }
  .count-tile { width: 22px; height: 42px; }
  .count-pips { font-size: 1rem; }
  .count-total { font-size: 0.9rem; padding: 8px 12px; }
  .final-score-row { padding: 8px 12px; min-width: auto; font-size: 0.85rem; }
  .message-box { padding: 20px 16px; max-width: 90%; }
  .xp-level { font-size: 0.55rem; padding: 2px 6px; }
  .xp-bar { width: 50px; height: 4px; }
  .match-badge { width: 14px; height: 14px; font-size: 0.5rem; top: -3px; right: -3px; }
  .log-entry { padding: 6px 8px; font-size: 0.8rem; }
  .log-entry .log-avatar { width: 22px; height: 22px; }
  .tracker-grid { grid-template-columns: repeat(7, 1fr); gap: 2px; }
  .stats-panel, .shortcuts-panel { padding: 20px 16px; }
}

/* Opponent low tile warning */
.low-tiles-warn { font-size: 0.65rem; color: #e04a3a; font-weight: 700; text-align: center; animation: lowTilePulse 1s ease-in-out infinite; }
@keyframes lowTilePulse { 0%,100% { opacity: 0.7; } 50% { opacity: 1; } }

/* Pip count in hand */
.pip-count { font-size: 0.7rem; opacity: 0.5; font-weight: 700; font-family: 'Inter', monospace; }

/* Block warning */
.block-warning { position: fixed; bottom: 200px; left: 50%; transform: translateX(-50%); padding: 8px 20px; background: rgba(224,74,58,0.9); color: #fff; border-radius: 10px; font-weight: 700; font-size: 0.85rem; z-index: 11; pointer-events: none; animation: blockWarnIn 0.3s ease-out; }
@keyframes blockWarnIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } }

/* Scoring opportunity flash */
.score-opp-flash { position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); padding: 10px 24px; background: rgba(74,175,108,0.9); color: #fff; border-radius: 12px; font-weight: 800; font-size: 1rem; z-index: 11; pointer-events: none; animation: scoreOppIn 0.3s ease-out, scoreOppOut 0.4s ease-in 1.2s forwards; }
@keyframes scoreOppIn { from { opacity: 0; transform: translate(-50%,-50%) scale(0.8); } }
@keyframes scoreOppOut { to { opacity: 0; } }

/* Round timeline */
.timeline-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.04); font-size: 0.85rem; }
.timeline-round { font-weight: 700; opacity: 0.6; min-width: 50px; }
.timeline-scores { display: flex; gap: 12px; }
.timeline-score { font-weight: 700; }
.timeline-winner { color: #f0b840; }

/* Move timer */
.move-timer { font-size: 0.65rem; opacity: 0.35; font-family: 'Inter', monospace; }


/* ===== Light Theme ===== */
body[data-theme="light"] {
  background: #e8f0e4;
  color: #1a2e1a;
}
body[data-theme="light"]::before {
  background:
    radial-gradient(ellipse at 50% 50%, transparent 40%, rgba(255,255,255,0.3) 100%),
    radial-gradient(ellipse at 50% 50%, #c8e6c0 0%, #a8d8a0 40%, #88c880 80%);
}
body[data-theme="light"]::after { opacity: 0.03; }
body[data-theme="light"] .menu-container {
  background: linear-gradient(145deg, rgba(255,255,255,0.85), rgba(240,240,235,0.95));
  border-color: rgba(0,0,0,0.08);
  box-shadow: 0 0 80px rgba(0,0,0,0.08), 0 30px 80px rgba(0,0,0,0.12);
  color: #1a2e1a;
}
body[data-theme="light"] .game-title {
  background: linear-gradient(180deg, #2a5a2a 10%, #c07800 50%, #8a5a00);
  -webkit-background-clip: text; background-clip: text;
}
body[data-theme="light"] .subtitle {
  background: linear-gradient(180deg, rgba(0,0,0,0.5), rgba(0,0,0,0.25));
  -webkit-background-clip: text; background-clip: text;
}
body[data-theme="light"] .title-tile { opacity: 0.4; }
body[data-theme="light"] .option-group label { color: #666; }
body[data-theme="light"] .btn-option {
  background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.12); color: #333;
}
body[data-theme="light"] .btn-option:hover { background: rgba(0,0,0,0.08); border-color: rgba(0,0,0,0.2); }
body[data-theme="light"] .btn-option.active { color: #1a1a1a; }
body[data-theme="light"] #player-roster {
  background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.06);
}
body[data-theme="light"] .roster-card {
  background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.06); color: #1a2e1a;
}
body[data-theme="light"] .roster-card.human { background: rgba(232,167,53,0.08); border-color: rgba(232,167,53,0.25); }
body[data-theme="light"] .roster-card:hover { background: rgba(0,0,0,0.06); }
body[data-theme="light"] #score-bar {
  background: linear-gradient(180deg, rgba(255,255,255,0.8), rgba(240,240,235,0.7));
  border-bottom-color: rgba(0,0,0,0.08);
}
body[data-theme="light"] .sb-team, body[data-theme="light"] .sb-player-score {
  background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.06);
}
body[data-theme="light"] .sb-team-name, body[data-theme="light"] .sb-ps-name { color: #333; }
body[data-theme="light"] #board-area {
  border-color: rgba(90,60,20,0.2);
  box-shadow: inset 0 0 40px rgba(0,0,0,0.1);
}
body[data-theme="light"] .opponent-hand.top { background: linear-gradient(180deg, rgba(255,255,255,0.4), transparent); }
body[data-theme="light"] .opponent-hand.left { background: linear-gradient(90deg, rgba(255,255,255,0.3), transparent); }
body[data-theme="light"] .opponent-hand.right { background: linear-gradient(-90deg, rgba(255,255,255,0.3), transparent); }
body[data-theme="light"] .opp-name { color: rgba(0,0,0,0.8); }
body[data-theme="light"] .opp-record { color: #666; }
body[data-theme="light"] #bottom-bar {
  background: linear-gradient(0deg, rgba(255,255,255,0.5), rgba(255,255,255,0.2));
  border-top-color: rgba(0,0,0,0.08);
}
body[data-theme="light"] #end-sum-display {
  background: linear-gradient(145deg, rgba(255,255,255,0.9), rgba(240,240,235,0.85));
  border-color: rgba(0,0,0,0.08); color: #333;
}
body[data-theme="light"] .message-box,
body[data-theme="light"] .rules-panel,
body[data-theme="light"] .log-panel,
body[data-theme="light"] .shortcuts-panel,
body[data-theme="light"] .stats-panel,
body[data-theme="light"] .tracker-panel {
  background: linear-gradient(145deg, #fafafa, #f0f0ec);
  border-color: rgba(0,0,0,0.08); color: #1a2e1a;
}
body[data-theme="light"] .message-box p { color: #333; }
body[data-theme="light"] .gm-btn { background: rgba(0,0,0,0.05); border-color: rgba(0,0,0,0.1); color: #333; }
body[data-theme="light"] .gm-btn:hover { background: rgba(0,0,0,0.1); }
body[data-theme="light"] #game-dropdown {
  background: linear-gradient(145deg, rgba(255,255,255,0.95), rgba(245,245,240,0.98));
  border-color: rgba(0,0,0,0.1);
}
body[data-theme="light"] .dd-item { color: #333; }
body[data-theme="light"] .dd-item:hover { background: rgba(0,0,0,0.06); }
body[data-theme="light"] .btn-menu {
  background: linear-gradient(145deg, rgba(255,255,255,0.7), rgba(240,240,235,0.5));
  border-color: rgba(0,0,0,0.1); color: #333;
}
body[data-theme="light"] .think-card {
  background: linear-gradient(145deg, rgba(255,255,255,0.92), rgba(245,245,240,0.95));
  border-color: rgba(0,0,0,0.08); color: #333;
}
body[data-theme="light"] .speech-bubble {
  background: linear-gradient(145deg, rgba(255,255,255,0.95), rgba(245,245,240,0.98));
  border-color: rgba(0,0,0,0.1); color: #333;
}
body[data-theme="light"] #turn-indicator {
  background: linear-gradient(145deg, rgba(255,255,255,0.92), rgba(245,245,240,0.95));
  border-color: rgba(0,0,0,0.08);
}
body[data-theme="light"] #turn-indicator .toast-text { color: #333; }
body[data-theme="light"] .name-edit {
  background: rgba(0,0,0,0.05); border-color: rgba(0,0,0,0.15); color: #333;
}
body[data-theme="light"] .pref-label { color: #666; }
body[data-theme="light"] .skin-option { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.1); color: #333; }
body[data-theme="light"] .skin-option:hover { background: rgba(0,0,0,0.06); }
body[data-theme="light"] .toggle-row span { color: #333; }
body[data-theme="light"] .toggle-slider { background: rgba(0,0,0,0.15); }
body[data-theme="light"] .stat-row { border-bottom-color: rgba(0,0,0,0.06); color: #333; }
body[data-theme="light"] .stat-label { color: #555; }
body[data-theme="light"] .log-entry { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.04); color: #333; }
body[data-theme="light"] .sc-row { border-bottom-color: rgba(0,0,0,0.06); color: #333; }
body[data-theme="light"] .sc-row span { color: #555; }
body[data-theme="light"] .sc-row kbd { background: rgba(0,0,0,0.08); border-color: rgba(0,0,0,0.15); }
body[data-theme="light"] .rules-content p { color: #444; }
body[data-theme="light"] .final-score-row { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.06); color: #333; }
body[data-theme="light"] .analysis-row { border-bottom-color: rgba(0,0,0,0.06); color: #333; }
body[data-theme="light"] .timeline-row { border-bottom-color: rgba(0,0,0,0.06); color: #333; }
body[data-theme="light"] .tracker-tile.unplayed { background: rgba(0,0,0,0.06); color: #333; }
body[data-theme="light"] .count-player { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.06); color: #333; }

/* ===== Roster re-roll button ===== */
.roster-reroll {
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12);
  color: #fff; width: 36px; height: 36px; border-radius: 50%;
  cursor: pointer; font-size: 1.1rem; display: flex; align-items: center; justify-content: center;
  transition: all 0.25s; flex-shrink: 0;
}
.roster-reroll:hover { background: rgba(255,255,255,0.15); transform: rotate(180deg) scale(1.1); }
body[data-theme="light"] .roster-reroll {
  background: rgba(0,0,0,0.06); border-color: rgba(0,0,0,0.12);
}
body[data-theme="light"] .roster-reroll:hover { background: rgba(0,0,0,0.12); }

/* ===== Drag ghost ===== */
.drag-ghost {
  box-shadow: 0 12px 40px rgba(0,0,0,0.5), 0 0 30px rgba(232,167,53,0.3);
  cursor: grabbing;
}

/* Dropdown shortcut key badges */
.dd-key {
  float: right; display: inline-block; min-width: 22px; padding: 2px 6px;
  text-align: center; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px; font-family: 'Inter', monospace; font-size: 0.7rem; font-weight: 700;
  color: rgba(255,255,255,0.4); margin-left: 12px; line-height: 1.3;
}
body[data-theme="light"] .dd-key {
  background: rgba(0,0,0,0.06); border-color: rgba(0,0,0,0.12); color: rgba(0,0,0,0.35);
}


/* ===== Last tile alert ===== */
.last-tile-alert {
  animation: lastTileFlash 0.6s ease-in-out infinite;
  font-weight: 900; color: #e04a3a;
}
@keyframes lastTileFlash {
  0%, 100% { opacity: 1; } 50% { opacity: 0.4; }
}

/* ===== Colorblind mode ===== */
body.colorblind .hand-tile.playable {
  border: 3px solid #fff;
  box-shadow: 0 2px 0 #3a9a5a, 0 4px 0 #2a8a4a, 0 6px 0 #1a7a3a, 0 8px 0 #0a6a2a,
    0 10px 20px rgba(0,0,0,0.4), 0 0 18px rgba(74,175,108,0.25), inset 0 2px 0 rgba(255,255,255,0.9);
}
body.colorblind .hand-tile.playable::after {
  content: '▶'; position: absolute; top: 2px; left: 2px;
  font-size: 0.6rem; color: #fff; background: rgba(0,0,0,0.5);
  width: 14px; height: 14px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; z-index: 3;
}
body.colorblind .hand-tile.not-playable::after {
  content: '✕'; position: absolute; top: 2px; left: 2px;
  font-size: 0.6rem; color: #fff; background: rgba(0,0,0,0.4);
  width: 14px; height: 14px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; z-index: 3;
}
body.colorblind .hand-tile.hint-glow {
  border: 3px dashed #a855f7;
}
body.colorblind .match-badge {
  border: 2px solid #fff;
}

/* ===== Custom score input ===== */
#custom-score-input {
  text-align: center; font-size: 1.1rem; font-weight: 700;
}

/* ===== Zoom controls ===== */
#zoom-controls {
  position: absolute; bottom: 80px; right: 10px; z-index: 5;
  display: flex; flex-direction: column; gap: 4px;
}
.zoom-btn {
  width: 36px; height: 36px; border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.45); backdrop-filter: blur(6px);
  color: #fff; font-size: 1.2rem; font-weight: 700; border-radius: 8px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; line-height: 1;
}
.zoom-btn:hover { background: rgba(0,0,0,0.65); border-color: rgba(255,255,255,0.25); transform: scale(1.08); }
.zoom-btn:active { transform: scale(0.95); }
body[data-theme="light"] .zoom-btn {
  background: rgba(255,255,255,0.6); border-color: rgba(0,0,0,0.12); color: #333;
}
body[data-theme="light"] .zoom-btn:hover { background: rgba(255,255,255,0.8); }
@media (max-width: 600px) {
  .zoom-btn { width: 30px; height: 30px; font-size: 1rem; border-radius: 6px; }
}


/* ===== Mobile & Tablet Polish ===== */

/* Safe areas for notched phones */
@supports (padding: env(safe-area-inset-top)) {
  #score-bar { padding-top: max(8px, env(safe-area-inset-top)); }
  #bottom-bar { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .btn-menu { top: max(10px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); }
  #end-sum-display { top: max(10px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); }
  .opponent-hand.left { padding-left: max(4px, env(safe-area-inset-left)); }
  .opponent-hand.right { padding-right: max(4px, env(safe-area-inset-right)); }
  #game-dropdown { left: max(10px, env(safe-area-inset-left)); }
  .menu-container { padding-top: max(44px, calc(env(safe-area-inset-top) + 20px)); padding-bottom: max(44px, calc(env(safe-area-inset-bottom) + 20px)); }
}

/* Button groups wrap on narrow screens */
.btn-group { flex-wrap: wrap; }

/* Touch-friendly board */
#board-canvas { touch-action: none; }

/* iPad / Tablet (768-1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
  .menu-container { padding: 36px 44px; max-width: 520px; }
  .hand-tile { width: 56px; height: 112px; }
  #player-hand { gap: 8px; }
  .opponent-hand.left, .opponent-hand.right { width: 72px; }
  .opp-avatar { width: 44px; height: 44px; }
  #human-info .human-avatar { width: 40px; height: 40px; }
  .btn-draw, .btn-pass, .btn-hint { padding: 8px 18px; font-size: 0.85rem; }
  #boneyard-area { min-height: 46px; }
  .final-score-row { min-width: 320px; }
}

/* iPad landscape */
@media (min-width: 1024px) and (max-height: 800px) {
  .opponent-hand.top { min-height: 60px; }
  #player-hand { max-height: 150px; }
}

/* Phone landscape */
@media (max-height: 500px) {
  .opponent-hand.top { min-height: 36px; padding: 2px 6px; }
  .opp-avatar { width: 24px; height: 24px; }
  .opp-name { font-size: 0.55rem; }
  .opp-info { gap: 0; }
  .opp-record, .personality-badge { display: none; }
  #player-hand { max-height: 80px; min-height: 50px; padding: 3px 8px; }
  .hand-tile { width: 36px; height: 72px; border-radius: 5px; }
  #human-info { padding: 2px 8px; gap: 6px; }
  #human-info .human-avatar { width: 24px; height: 24px; }
  #human-info .human-name { font-size: 0.65rem; }
  #player-controls { gap: 4px; }
  .btn-draw, .btn-pass, .btn-hint { padding: 4px 8px; font-size: 0.6rem; }
  #boneyard-area { min-height: 24px; padding: 2px 6px; }
  #boneyard-tiles { width: 40px; height: 16px; }
  .bone-tile { width: 10px; height: 5px; }
  #boneyard-label { font-size: 0.55rem; }
  #boneyard-count { min-width: 20px; height: 20px; font-size: 0.7rem; padding: 0 4px; }
  #score-bar { padding: 2px 6px; }
  .sb-team-score, .sb-ps-score { font-size: 0.8rem; }
  .opponent-hand.left, .opponent-hand.right { width: 40px; }
  .face-down { width: 14px; height: 7px; }
  .face-down.vertical { width: 7px; height: 14px; }
  #end-sum-display { display: none; }
  .score-popup { font-size: 1.8rem; }
  .score-popup .score-label { font-size: 0.6rem; }
}

/* Fix game over on small phones */
@media (max-width: 400px) {
  .final-score-row { min-width: auto; padding: 10px 12px; font-size: 0.8rem; }
  .final-score-row img { width: 32px; height: 32px; }
  #final-scores { margin: 12px 0; }
  .game-title { font-size: 1.5rem; letter-spacing: 2px; }
  .btn-start { padding: 10px 24px; font-size: 0.9rem; margin-top: 16px; }
  .menu-container { padding: 16px 12px; border-radius: 14px; }
  .btn-option { padding: 6px 4px; font-size: 0.7rem; border-radius: 6px; }
  .option-group { margin-bottom: 12px; }
  .roster-card .roster-avatar { width: 32px; height: 32px; }
  .roster-card { padding: 6px 8px; gap: 6px; margin: 4px 0; }
  .roster-card .roster-name { font-size: 0.8rem; }
  .roster-card .roster-rank { font-size: 0.65rem; }
  .roster-card .roster-record { font-size: 0.6rem; }
  .roster-reroll { width: 28px; height: 28px; font-size: 0.85rem; }
  .count-player { min-width: auto; flex-wrap: wrap; }
  .hand-tile { width: 40px; height: 80px; }
  .hand-tile .half svg { width: 32px; height: 32px; }
  #player-hand { gap: 4px; }
  .opponent-hand.left, .opponent-hand.right { width: 36px; }
  .opp-avatar { width: 20px; height: 20px; }
  .opp-name { font-size: 0.5rem; }
  #end-sum-display { max-width: 100px; padding: 3px 6px; }
}

/* Boneyard count badge responsive */
@media (max-width: 600px) {
  #boneyard-count { min-width: 22px; height: 22px; font-size: 0.75rem; padding: 0 4px; border-radius: 6px; }
  #boneyard-label { font-size: 0.7rem; gap: 4px; }
}
@media (max-width: 480px) {
  #boneyard-count { min-width: 18px; height: 18px; font-size: 0.65rem; padding: 0 3px; border-radius: 4px; }
}

/* Round intro avatars responsive */
#round-intro { padding: 20px; }
@media (max-width: 600px) {
  #round-intro img { width: 52px !important; height: 52px !important; }
}
@media (max-width: 400px) {
  #round-intro img { width: 44px !important; height: 44px !important; }
}

/* Dropdown key badges hide on small screens */
@media (max-width: 480px) {
  .dd-key { display: none; }
}

/* Score bar overflow handling */
#score-bar-content { overflow: hidden; }
.sb-ps-name { max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 480px) {
  .sb-ps-name { max-width: 36px; font-size: 0.6rem; }
  .sb-team-name { max-width: 50px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.6rem; }
}

/* Zoom controls mobile */
@media (max-width: 480px) {
  #zoom-controls { bottom: 140px; right: 4px; }
  .zoom-btn { width: 26px; height: 26px; font-size: 0.85rem; border-radius: 5px; }
}

/* Ensure overlays are scrollable on small screens */
.stats-panel, .log-panel, .rules-panel, .shortcuts-panel, .tracker-panel {
  max-height: 85vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
@media (max-width: 480px) {
  .stats-panel, .log-panel, .rules-panel, .shortcuts-panel, .tracker-panel {
    max-height: 90vh; width: 95%; padding: 16px 12px;
  }
}

/* Message box responsive */
@media (max-width: 400px) {
  .message-box { padding: 16px 12px; max-width: 95%; }
  .message-box p { font-size: 0.9rem; }
}

/* ===== Auto-play banner ===== */
.auto-play-banner {
  position: fixed; bottom: 180px; left: 50%; transform: translateX(-50%);
  padding: 10px 24px; border-radius: 12px; z-index: 20; pointer-events: none;
  background: linear-gradient(145deg, rgba(232,167,53,0.9), rgba(200,140,30,0.9));
  color: #1a1a1a; font-weight: 800; font-size: 0.9rem; letter-spacing: 0.5px;
  box-shadow: 0 4px 20px rgba(232,167,53,0.4), 0 0 30px rgba(232,167,53,0.15);
  animation: autoPlayIn 0.3s ease-out;
  white-space: nowrap;
  transition: opacity 0.4s ease;
}
.auto-play-banner.fade-out { opacity: 0; }
@keyframes autoPlayIn { from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.9); } to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); } }
@media (max-width: 480px) {
  .auto-play-banner { font-size: 0.75rem; padding: 8px 16px; bottom: 140px; }
}

/* ===== RTL support (Arabic) ===== */
[dir="rtl"] .option-group { text-align: right; }
[dir="rtl"] .roster-card { direction: rtl; }
[dir="rtl"] .opp-info { text-align: right; }
[dir="rtl"] #human-info .human-info-text { text-align: right; }
[dir="rtl"] #player-controls { margin-left: 0; margin-right: auto; }
[dir="rtl"] .btn-menu { left: auto; right: 10px; }
[dir="rtl"] #game-dropdown { left: auto; right: 10px; }
[dir="rtl"] .dd-item { text-align: right; }
[dir="rtl"] .dd-key { float: left; margin-left: 0; margin-right: 12px; }
[dir="rtl"] #end-sum-display { right: auto; left: 14px; }
[dir="rtl"] #turn-indicator { left: auto; right: 16px; bottom: 160px; }
[dir="rtl"] .log-entry { direction: rtl; }
[dir="rtl"] .stat-row { direction: rtl; }
[dir="rtl"] .speech-bubble { direction: rtl; }
[dir="rtl"] #zoom-controls { right: auto; left: 10px; }
@supports (padding: env(safe-area-inset-top)) {
  [dir="rtl"] .btn-menu { left: auto; right: max(10px, env(safe-area-inset-right)); }
  [dir="rtl"] #game-dropdown { left: auto; right: max(10px, env(safe-area-inset-right)); }
  [dir="rtl"] #end-sum-display { left: max(14px, env(safe-area-inset-left)); right: auto; }
  [dir="rtl"] .opponent-hand.left { padding-right: max(4px, env(safe-area-inset-right)); padding-left: 4px; }
  [dir="rtl"] .opponent-hand.right { padding-left: max(4px, env(safe-area-inset-left)); padding-right: 4px; }
}

/* ===== Menu language selector ===== */
#menu-lang-selector .btn-option {
  font-size: 1.3rem; padding: 6px 10px; min-width: auto; flex: 0;
  border-radius: 10px;
}
#menu-lang-selector .btn-option.active {
  box-shadow: 0 2px 12px rgba(232,167,53,0.4);
}

/* ===== Screen shake on big scores ===== */
@keyframes boardShake {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-4px, 2px); }
  20% { transform: translate(4px, -2px); }
  30% { transform: translate(-3px, -3px); }
  40% { transform: translate(3px, 3px); }
  50% { transform: translate(-2px, 1px); }
  60% { transform: translate(2px, -1px); }
  70% { transform: translate(-1px, 2px); }
  80% { transform: translate(1px, -1px); }
}
.board-shake { animation: boardShake 0.5s ease-out; }
@keyframes boardShakeHeavy {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  8% { transform: translate(-6px, 3px) rotate(-0.5deg); }
  16% { transform: translate(6px, -4px) rotate(0.5deg); }
  24% { transform: translate(-5px, -3px) rotate(-0.3deg); }
  32% { transform: translate(4px, 4px) rotate(0.3deg); }
  40% { transform: translate(-3px, 2px) rotate(-0.2deg); }
  50% { transform: translate(3px, -2px) rotate(0.1deg); }
  60% { transform: translate(-2px, 1px); }
  70% { transform: translate(1px, -1px); }
  80% { transform: translate(-1px, 1px); }
}
.board-shake-heavy { animation: boardShakeHeavy 0.6s ease-out; }

/* ===== Combo popup ===== */
.combo-popup {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  font-size: 2.5rem;
  font-weight: 900;
  color: #f0b840;
  text-shadow: 0 0 20px rgba(232,167,53,0.8), 0 4px 12px rgba(0,0,0,0.5);
  z-index: 80;
  pointer-events: none;
  opacity: 0;
  animation: comboIn 0.8s ease-out forwards;
  letter-spacing: 4px;
}
@keyframes comboIn {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  30% { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
  60% { transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}

/* Animated score counter */
.sb-team-score, .sb-ps-score {
  transition: all 0.3s ease-out;
}
.score-bump {
  animation: scoreBump 0.4s ease-out;
}
@keyframes scoreBump {
  0% { transform: scale(1); }
  40% { transform: scale(1.4); color: #f0b840; }
  100% { transform: scale(1); }
}

/* ===== Table cloth felt grain (fractal noise) ===== */
#board-area::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.055;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
}
/* Soft table-lamp light pool + edge falloff over the felt */
#board-area::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 62% 48% at 50% 38%, rgba(255,236,190,0.10), transparent 70%),
    radial-gradient(ellipse 95% 85% at 50% 50%, transparent 55%, rgba(0,0,0,0.28) 100%);
}

/* ===== Boneyard low pulse (#8) ===== */
.boneyard-low {
  animation: boneyardPulse 1s ease-in-out infinite;
}
@keyframes boneyardPulse {
  0%, 100% { background: linear-gradient(145deg, rgba(232,167,53,0.25), rgba(232,167,53,0.1)); color: #f0b840; }
  50% { background: linear-gradient(145deg, rgba(224,74,58,0.4), rgba(224,74,58,0.2)); color: #ff6b5b; }
}

/* ===== First blood banner (#6) ===== */
.first-blood-banner {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  font-size: 2rem;
  font-weight: 900;
  color: #e04a3a;
  text-shadow: 0 0 20px rgba(224,74,58,0.8), 0 4px 12px rgba(0,0,0,0.5);
  z-index: 80;
  pointer-events: none;
  opacity: 0;
  animation: firstBloodIn 1.5s ease-out forwards;
  letter-spacing: 3px;
  white-space: nowrap;
}
@keyframes firstBloodIn {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
  40% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}

/* ===== Perfect round popup (#11) ===== */
.perfect-round-popup {
  position: fixed;
  top: 35%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  font-size: 2.2rem;
  font-weight: 900;
  color: #f0b840;
  text-shadow: 0 0 24px rgba(232,167,53,0.9), 0 4px 12px rgba(0,0,0,0.5);
  z-index: 80;
  pointer-events: none;
  opacity: 0;
  animation: perfectRoundIn 2s ease-out forwards;
  letter-spacing: 3px;
  white-space: nowrap;
}
@keyframes perfectRoundIn {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
  35% { transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}

/* ===== Pip count badge (#2) ===== */
.pip-count {
  font-size: 0.65rem;
  opacity: 0.5;
  font-weight: 600;
}

/* ===== Prefers reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===========================================================================
   v1.3.0 polish: score orbs, match point mode, domino cascade victory
   =========================================================================== */

/* Score orbs — golden points flying from the board to the scorer's chip */
.score-orb {
  position: fixed; z-index: 90; pointer-events: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff3c0, #f0b840 55%, #c8901a);
  box-shadow: 0 0 12px rgba(240,184,64,0.9), 0 0 28px rgba(240,184,64,0.4);
  transition: left 0.7s cubic-bezier(0.5, -0.15, 0.4, 1), top 0.7s cubic-bezier(0.5, -0.15, 0.4, 1),
    transform 0.7s ease, opacity 0.7s ease;
}

/* Match point — pulsing red vignette over the game screen */
body.match-point #game-screen::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 4;
  background: radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(220,40,30,0.22) 100%);
  animation: matchPointPulse 1.6s ease-in-out infinite;
}
@keyframes matchPointPulse { 0%,100% { opacity: 0.35; } 50% { opacity: 1; } }
.match-point-banner {
  position: fixed; top: 38%; left: 50%; z-index: 96; pointer-events: none;
  transform: translate(-50%, -50%);
  font-size: clamp(1.6rem, 6vw, 3.2rem); font-weight: 900; letter-spacing: 6px;
  color: #ff5040; text-shadow: 0 0 24px rgba(220,40,30,0.8), 0 2px 8px rgba(0,0,0,0.7);
  animation: matchPointBanner 2.6s ease-out forwards;
}
@keyframes matchPointBanner {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(2.2); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  25% { transform: translate(-50%, -50%) scale(1.08); }
  35% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
}

/* Domino cascade — victory chain toppling across the screen */
.cascade-tile {
  position: absolute; pointer-events: none;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: 100% 100%;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.45));
}
.cascade-tile.standing { opacity: 1; transform: translateY(0); }
.cascade-tile.toppled {
  opacity: 1;
  transform: translateY(0) rotate(78deg);
  transition: transform 0.4s cubic-bezier(0.55, 0, 0.9, 1);
}

@media (prefers-reduced-motion: reduce) {
  .score-orb, .match-point-banner { display: none; }
  body.match-point #game-screen::after { animation: none; opacity: 0.4; }
}

/* ===========================================================================
   v1.4.0 polish: avatar emotes, DOMINO! stamp, fireworks, combo fire
   =========================================================================== */

/* Avatar emote reactions */
.avatar-emote {
  position: fixed; z-index: 60; pointer-events: none;
  font-size: 1.9rem;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  animation: emotePop 1.6s ease-out forwards;
}
@keyframes emotePop {
  0% { opacity: 0; transform: translateY(6px) scale(0.4); }
  18% { opacity: 1; transform: translateY(-8px) scale(1.25); }
  30% { transform: translateY(-12px) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-34px) scale(0.9); }
}
.avatar-react-shake { animation: avatarReactShake 0.5s ease-in-out; }
@keyframes avatarReactShake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-5px) rotate(-1deg); }
  40% { transform: translateX(5px) rotate(1deg); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

/* DOMINO! cinematic stamp + letterbox bars */
.letterbox-bar {
  position: fixed; left: 0; right: 0; height: 9vh; background: #000;
  z-index: 97; pointer-events: none;
  transition: transform 0.45s cubic-bezier(0.7, 0, 0.3, 1);
}
.letterbox-bar.top { top: 0; transform: translateY(-100%); }
.letterbox-bar.bottom { bottom: 0; transform: translateY(100%); }
.letterbox-bar.in { transform: translateY(0); }
.domino-stamp {
  position: fixed; top: 42%; left: 50%; z-index: 98; pointer-events: none;
  transform: translate(-50%, -50%) rotate(-10deg);
  font-size: clamp(2.4rem, 10vw, 6rem); font-weight: 900; letter-spacing: 4px;
  color: #fff;
  -webkit-text-stroke: 2px #f0b840;
  text-shadow: 0 0 30px rgba(240,184,64,0.7), 0 6px 0 rgba(160,110,20,0.8), 0 10px 30px rgba(0,0,0,0.8);
  animation: dominoStamp 1.7s cubic-bezier(0.2, 1.4, 0.4, 1) forwards;
}
@keyframes dominoStamp {
  0% { opacity: 0; transform: translate(-50%,-50%) rotate(-10deg) scale(3.2); }
  22% { opacity: 1; transform: translate(-50%,-50%) rotate(-10deg) scale(1); }
  30% { transform: translate(-50%,-50%) rotate(-8deg) scale(1.06); }
  38% { transform: translate(-50%,-50%) rotate(-10deg) scale(1); }
  82% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%,-50%) rotate(-10deg) scale(1.05); }
}

/* Victory fireworks */
.firework-streak {
  position: fixed; z-index: 96; pointer-events: none;
  width: 3px; height: 26px; border-radius: 2px;
  background: linear-gradient(180deg, #fff8d0, rgba(240,184,64,0.1));
  box-shadow: 0 0 8px rgba(255,240,180,0.8);
}
.firework-spark {
  position: fixed; z-index: 96; pointer-events: none;
  width: 5px; height: 5px; border-radius: 50%;
}

/* Combo fire streak on the human info bar */
#human-info.combo-fire {
  box-shadow: 0 -4px 24px rgba(240,120,30,0.45), inset 0 3px 18px rgba(240,120,30,0.18);
  transition: box-shadow 0.4s ease;
}
.particle-ember {
  position: fixed; z-index: 6; pointer-events: none; border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, #ffd080, #f07820 60%, rgba(200,60,10,0));
  box-shadow: 0 0 8px rgba(240,120,30,0.7);
}

@media (prefers-reduced-motion: reduce) {
  .avatar-emote, .domino-stamp, .letterbox-bar, .firework-streak, .firework-spark, .particle-ember { display: none; }
  #human-info.combo-fire { box-shadow: none; }
}
