/* ══════════════════════════════════════════
   ТОҒЫЗ ҚҰМАЛАҚ — Kazakh Ою-Өрнек Style
   Warm cream, crimson red, cobalt blue, gold
══════════════════════════════════════════ */

/* ── SVG Pattern Variables ── */
:root {
  /* Main color palette */
  --cream:    #FBF0D5;
  --cream-d:  #F0DFB0;
  --cream-dd: #E5CC90;
  --red:      #8B1A1A;
  --red-l:    #C02828;
  --red-ll:   #E03838;
  --cobalt:   #1B4372;
  --cobalt-l: #2E6DA4;
  --gold:     #C9A84C;
  --gold-l:   #E8C85A;
  --gold-d:   #8A6820;
  --green:    #2D6040;
  --text:     #2A1005;
  --text-m:   #6B4028;
  --text-l:   #A07050;
  --border:   rgba(139,26,26,0.2);
  --border-l: rgba(139,26,26,0.4);
  --shadow:   rgba(60,20,5,0.2);

  /* Ою border: alternating red-gold-blue-gold diamonds on cream */
  --oyu-h: 20px;
  --oyu-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='20'%3E%3Crect width='80' height='20' fill='%23C9A84C'/%3E%3Cpolygon points='10,2 18,10 10,18 2,10' fill='%238B1A1A'/%3E%3Cpolygon points='30,2 38,10 30,18 22,10' fill='%23FBF0D5'/%3E%3Cpolygon points='50,2 58,10 50,18 42,10' fill='%231B4372'/%3E%3Cpolygon points='70,2 78,10 70,18 62,10' fill='%23FBF0D5'/%3E%3Ccircle cx='10' cy='10' r='2' fill='%23E8C85A'/%3E%3Ccircle cx='30' cy='10' r='2' fill='%23C9A84C'/%3E%3Ccircle cx='50' cy='10' r='2' fill='%23E8C85A'/%3E%3Ccircle cx='70' cy='10' r='2' fill='%23C9A84C'/%3E%3C/svg%3E");

  /* Blue-variant oyu border */
  --oyu-blue: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='20'%3E%3Crect width='80' height='20' fill='%231B4372'/%3E%3Cpolygon points='10,2 18,10 10,18 2,10' fill='%23FBF0D5'/%3E%3Cpolygon points='30,2 38,10 30,18 22,10' fill='%23C9A84C'/%3E%3Cpolygon points='50,2 58,10 50,18 42,10' fill='%23FBF0D5'/%3E%3Cpolygon points='70,2 78,10 70,18 62,10' fill='%23C9A84C'/%3E%3Ccircle cx='10' cy='10' r='2' fill='%23E8C85A'/%3E%3Ccircle cx='30' cy='10' r='2' fill='%238B1A1A'/%3E%3Ccircle cx='50' cy='10' r='2' fill='%23E8C85A'/%3E%3Ccircle cx='70' cy='10' r='2' fill='%238B1A1A'/%3E%3C/svg%3E");

  /* Background diamond grid (subtle, on cream) */
  --bg-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cpolygon points='40,5 75,40 40,75 5,40' fill='none' stroke='rgba(139,26,26,0.12)' stroke-width='1.5'/%3E%3Cpolygon points='40,20 60,40 40,60 20,40' fill='none' stroke='rgba(27,67,114,0.08)' stroke-width='1'/%3E%3Cpolygon points='40,2 43,5 40,8 37,5' fill='rgba(201,168,76,0.35)'/%3E%3Cpolygon points='40,72 43,75 40,78 37,75' fill='rgba(201,168,76,0.35)'/%3E%3Cpolygon points='2,40 5,37 8,40 5,43' fill='rgba(201,168,76,0.35)'/%3E%3Cpolygon points='72,40 75,37 78,40 75,43' fill='rgba(201,168,76,0.35)'/%3E%3C/svg%3E");

  /* Board wood grain */
  --board-bg: linear-gradient(160deg, #9B6030 0%, #7A4520 40%, #5E3210 100%);

  --t: 0.22s cubic-bezier(0.4,0,0.2,1);
}

/* ── Reset ── */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%;overflow:hidden}
body{font-family:'Cinzel',Georgia,serif;background:var(--cream);color:var(--text)}
input,button,select{font-family:inherit;outline:none}
button{cursor:pointer;border:none;background:none}

/* ── Screen system ── */
.screen{position:fixed;inset:0;display:none;flex-direction:column;overflow:hidden}
.screen.active{display:flex}

/* ══════════════════════════════════════════
   ОЮ-ӨРНЕК BORDER STRIP
══════════════════════════════════════════ */
.oyu-strip {
  height: var(--oyu-h);
  background-image: var(--oyu-img);
  background-repeat: repeat-x;
  background-size: 80px var(--oyu-h);
  flex-shrink: 0;
}
.blue-oyu { background-image: var(--oyu-blue); }

/* Thick ою bar used below headers */
.oyu-topbar {
  height: 22px;
  background-image: var(--oyu-img);
  background-repeat: repeat-x;
  background-size: 80px 22px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(139,26,26,0.15);
}
.game-oyu { background-image: var(--oyu-blue); }

/* ══════════════════════════════════════════
   GLOBAL CONTROLS
══════════════════════════════════════════ */
#g-controls {
  position: fixed; top: 0; right: 0; z-index: 500;
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px;
  background: var(--red);
  border-bottom-left-radius: 12px;
  box-shadow: 0 2px 12px rgba(139,26,26,0.35);
}
.lang-group { display: flex; gap: 3px; }
.lang-btn {
  padding: 4px 10px; font-size: .62rem; letter-spacing: .06em;
  background: rgba(255,255,255,0.15); color: rgba(255,255,255,0.8);
  border: 1px solid rgba(255,255,255,0.25); border-radius: 4px;
  transition: all var(--t); font-family: 'Cinzel', serif;
}
.lang-btn:hover { background: rgba(255,255,255,0.3); color: #fff; }
.lang-btn.active { background: var(--gold); color: var(--red); font-weight: 700; border-color: var(--gold-l); }
.g-rules-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 11px; font-size: .62rem; letter-spacing: .06em;
  color: var(--gold-l); border: 1px solid rgba(201,168,76,0.5); border-radius: 4px;
  background: rgba(201,168,76,0.12); transition: all var(--t);
}
.g-rules-btn:hover { background: rgba(201,168,76,0.25); }

/* ══════════════════════════════════════════
   TOP BAR
══════════════════════════════════════════ */
.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; padding-right: 210px;
  background: var(--red);
  flex-shrink: 0; z-index: 10;
}
.top-logo {
  font-family: 'Cinzel Decorative', serif; font-size: .78rem;
  color: var(--gold-l); letter-spacing: .1em;
}
.top-right { display: flex; align-items: center; gap: 10px; }
.top-user { display: flex; align-items: center; gap: 7px; color: rgba(255,255,255,0.85); font-size: .75rem; }
.av-sm {
  width: 26px; height: 26px; border-radius: 50%; background: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700; color: var(--red);
}
.btn-back {
  color: rgba(255,255,255,0.8); font-size: .72rem; padding: 4px 8px;
  border-radius: 4px; transition: color var(--t);
}
.btn-back:hover { color: var(--gold-l); }
.btn-outline-sm {
  padding: 5px 12px; border: 1px solid rgba(255,255,255,0.3); border-radius: 5px;
  color: rgba(255,255,255,0.7); font-size: .65rem; letter-spacing: .05em;
  transition: all var(--t);
}
.btn-outline-sm:hover { border-color: var(--gold-l); color: var(--gold-l); }
.room-pill {
  background: var(--gold); color: var(--red); font-family: 'Cinzel Decorative', serif;
  font-size: .78rem; letter-spacing: .15em; padding: 3px 12px; border-radius: 20px;
  font-weight: 700;
}

/* ══════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════ */
.btn-red {
  padding: 12px 20px; background: var(--red); color: var(--cream);
  font-family: 'Cinzel', serif; font-size: .82rem; font-weight: 700; letter-spacing: .08em;
  border-radius: 8px; border: 2px solid var(--red-l);
  box-shadow: 0 4px 14px rgba(139,26,26,0.3), inset 0 1px 0 rgba(255,255,255,0.15);
  transition: all var(--t);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-red:hover:not(:disabled) { background: var(--red-l); transform: translateY(-2px); box-shadow: 0 8px 22px rgba(139,26,26,0.35); }
.btn-red:active { transform: none; }
.btn-red:disabled { opacity: .4; cursor: not-allowed; }
.btn-red.full { width: 100%; }
.btn-cobalt {
  padding: 10px 20px; background: var(--cobalt); color: #fff;
  font-family: 'Cinzel', serif; font-size: .78rem; font-weight: 600; letter-spacing: .06em;
  border-radius: 8px; border: 2px solid var(--cobalt-l);
  box-shadow: 0 4px 14px rgba(27,67,114,0.3); transition: all var(--t);
}
.btn-cobalt:hover { background: var(--cobalt-l); transform: translateY(-2px); }

/* ══════════════════════════════════════════
   FORM FIELDS
══════════════════════════════════════════ */
.f-label {
  display: block; font-size: .65rem; letter-spacing: .13em; text-transform: uppercase;
  color: var(--text-m); margin-bottom: 6px; font-family: 'Cinzel', serif;
}
.center-lbl { text-align: center; }
.f-input {
  width: 100%; padding: 10px 13px;
  background: var(--cream); border: 2px solid var(--cream-dd); border-radius: 7px;
  color: var(--text); font-size: .9rem; transition: border-color var(--t);
  font-family: 'Lora', Georgia, serif;
}
.f-input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(139,26,26,0.1); }
.f-input::placeholder { color: var(--text-l); }
.field-grp { margin-bottom: 14px; }
.pw-wrap { position: relative; }
.pw-wrap .f-input { padding-right: 40px; }
.pw-eye {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 1rem; color: var(--text-l);
  transition: color var(--t); padding: 2px;
}
.pw-eye:hover { color: var(--red); }
.form-err { font-size: .72rem; color: var(--red-l); min-height: 1.1em; margin-bottom: 6px; font-family: 'Lora', serif; }
.opt-tag { font-size: .7em; color: var(--text-l); font-style: italic; }

/* ══════════════════════════════════════════
   MODAL SYSTEM
══════════════════════════════════════════ */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 300;
  background: rgba(60,20,5,0.65); backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; animation: fadeIn .2s; }
.modal-box {
  background: var(--cream); border: 2px solid var(--red);
  border-radius: 14px; overflow: hidden; width: 90%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(60,20,5,0.4);
  animation: slideUp .28s cubic-bezier(.34,1.56,.64,1);
}
.modal-inner { padding: 28px 30px; position: relative; }
.modal-close {
  position: absolute; top: 12px; right: 14px;
  color: var(--text-l); font-size: .9rem; padding: 4px 6px; transition: color var(--t);
}
.modal-close:hover { color: var(--red); }
.modal-ornament { text-align: center; font-size: 1.6rem; color: var(--gold); margin-bottom: 10px; }
.modal-title {
  font-family: 'Cinzel Decorative', serif; font-size: 1rem; color: var(--red);
  text-align: center; margin-bottom: 22px;
}
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
@keyframes slideUp { from{transform:translateY(20px) scale(.96);opacity:0} to{transform:none;opacity:1} }

/* ══════════════════════════════════════════
   SCREEN: AUTH
══════════════════════════════════════════ */
#screen-auth { overflow: hidden; background: var(--cream); }
.auth-bg { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.auth-pattern-overlay {
  position: absolute; inset: 0;
  background-image: var(--bg-pattern); background-size: 80px 80px;
}
.auth-scroll {
  position: relative; z-index: 1; overflow-y: auto; flex: 1;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.auth-wrap {
  width: 100%; max-width: 440px;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
}

/* Logo */
.auth-logo { text-align: center; }
.auth-oyu-row { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 8px; }
.oyu-star { font-size: 1.8rem; color: var(--gold); animation: rotateSlow 12s linear infinite; }
@keyframes rotateSlow { to { transform: rotate(360deg); } }
.oyu-horn {
  width: 48px; height: 18px; position: relative;
}
.oyu-horn::before, .oyu-horn::after {
  content: ''; position: absolute;
  border: 2px solid var(--red); border-radius: 50%; opacity: .7;
}
.oyu-horn.left::before { width: 28px; height: 18px; right: 0; top: 0; border-left: none; border-top: none; transform: rotate(-25deg); }
.oyu-horn.left::after { width: 14px; height: 10px; right: 10px; top: 4px; border-left: none; border-top: none; transform: rotate(-25deg); }
.oyu-horn.right::before { width: 28px; height: 18px; left: 0; top: 0; border-right: none; border-top: none; transform: rotate(25deg); }
.oyu-horn.right::after { width: 14px; height: 10px; left: 10px; top: 4px; border-right: none; border-top: none; transform: rotate(25deg); }

.auth-title {
  font-family: 'Cinzel Decorative', serif;
  font-size: clamp(1.3rem, 4vw, 2rem);
  color: var(--red); letter-spacing: .05em;
  text-shadow: 2px 2px 0 var(--cream-dd), 0 0 30px rgba(139,26,26,0.2);
}
.auth-sub { font-size: .68rem; letter-spacing: .2em; text-transform: uppercase; color: var(--text-m); margin-top: 4px; font-family: 'Lora', serif; font-style: italic; }

/* Auth card */
.auth-card {
  width: 100%;
  background: #fff; border: 2px solid var(--red); border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(139,26,26,0.2), 0 0 0 1px rgba(201,168,76,0.3);
}
.auth-tabs { display: flex; border-bottom: 2px solid var(--cream-dd); }
.auth-tab {
  flex: 1; padding: 13px 10px; font-size: .73rem; letter-spacing: .1em;
  color: var(--text-m); border-bottom: 3px solid transparent; margin-bottom: -2px;
  transition: all var(--t); text-transform: uppercase; font-family: 'Cinzel', serif;
}
.auth-tab.active { color: var(--red); border-bottom-color: var(--red); font-weight: 700; }
.auth-tabs.hidden { display: none; }

.tab-pane { display: none; padding: 24px 26px; }
.tab-pane.active { display: block; }

.auth-links { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 12px; font-size: .72rem; color: var(--text-m); font-family: 'Lora', serif; }
.lnk { color: var(--red); font-size: .72rem; text-decoration: underline; transition: color var(--t); font-family: 'Lora', serif; }
.lnk:hover { color: var(--red-l); }
.back-lnk { display: block; text-align: center; margin-top: 10px; color: var(--text-l) !important; }

/* Step panes */
.step-icon { font-size: 2.2rem; text-align: center; margin-bottom: 8px; animation: bounceIn .5s cubic-bezier(.34,1.56,.64,1) both; }
@keyframes bounceIn { from{transform:scale(0);opacity:0} to{transform:none;opacity:1} }
.step-title { font-family: 'Cinzel Decorative', serif; font-size: .9rem; color: var(--red); text-align: center; margin-bottom: 6px; }
.step-desc { font-size: .75rem; color: var(--text-m); text-align: center; margin-bottom: 16px; font-family: 'Lora', serif; font-style: italic; line-height: 1.5; }

/* Demo banner */
.demo-banner {
  background: linear-gradient(135deg, #fff8e1, #fff3cc);
  border: 1.5px solid var(--gold); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 16px; text-align: center;
  display: flex; flex-direction: column; gap: 4px;
}
.demo-tag {
  display: inline-block; background: var(--gold); color: var(--red);
  font-size: .58rem; font-weight: 700; letter-spacing: .15em; padding: 2px 8px;
  border-radius: 10px; font-family: 'Cinzel', serif; margin-bottom: 4px;
}
.demo-banner > span { font-size: .72rem; color: var(--text-m); font-family: 'Lora', serif; }
.demo-code {
  font-family: 'Cinzel Decorative', serif; font-size: 1.8rem; color: var(--red);
  letter-spacing: .3em; animation: codePulse 2s infinite;
}
@keyframes codePulse { 0%,100%{opacity:1} 50%{opacity:.6} }

/* 6-digit code inputs */
.code-row { display: flex; gap: 7px; justify-content: center; margin: 8px 0; }
.cbox {
  width: 40px; height: 50px;
  background: var(--cream); border: 2px solid var(--cream-dd); border-radius: 8px;
  color: var(--red); font-family: 'Cinzel Decorative', serif; font-size: 1.3rem;
  text-align: center; transition: border-color var(--t), box-shadow var(--t);
}
.cbox:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(139,26,26,0.12); }
.cbox.filled { border-color: var(--red); background: rgba(139,26,26,0.04); }
.cbox.err { border-color: var(--red-ll); animation: shake .3s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-4px)} 75%{transform:translateX(4px)} }

.timer-row { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: .7rem; color: var(--text-m); font-family: 'Lora', serif; margin: 8px 0 14px; }
.timer { font-family: 'Cinzel', serif; color: var(--cobalt); font-size: .8rem; font-weight: 600; }
.timer.urgent { color: var(--red-l); animation: urgentFlash .8s infinite; }
@keyframes urgentFlash { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ══════════════════════════════════════════
   SCREEN: LOBBY
══════════════════════════════════════════ */
#screen-lobby { overflow-y: auto; }
.lobby-body {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 24px 20px; gap: 28px;
  background-image: var(--bg-pattern); background-size: 80px 80px;
  background-color: var(--cream);
}
.lobby-hero { text-align: center; }
.hero-ornament { font-size: 1.4rem; color: var(--gold); margin-bottom: 4px; opacity: .7; }
.hero-title { font-family: 'Cinzel Decorative', serif; font-size: clamp(1.1rem, 2.8vw, 1.6rem); color: var(--red); }
.hero-sub { font-size: .72rem; color: var(--text-m); margin-top: 5px; font-family: 'Lora', serif; font-style: italic; letter-spacing: .05em; }

.mode-cards { display: flex; align-items: stretch; gap: 0; max-width: 700px; width: 100%; }
.mode-sep { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 18px; flex-shrink: 0; }
.sep-line { width: 1px; flex: 1; background: var(--border); min-height: 30px; }
.sep-gem { font-size: .75rem; color: var(--gold-d); }

.mode-card {
  flex: 1; background: #fff;
  border: 2px solid var(--red); border-radius: 14px; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 6px 20px rgba(139,26,26,0.12);
  transition: transform var(--t), box-shadow var(--t);
  cursor: pointer;
}
.mode-card:hover { transform: translateY(-5px); box-shadow: 0 14px 36px rgba(139,26,26,0.2); }
.pvp-card { border-color: var(--cobalt); }
.pvp-card:hover { box-shadow: 0 14px 36px rgba(27,67,114,0.2); }

.mc-oyu-top, .mc-oyu-bot { height: var(--oyu-h); background-image: var(--oyu-img); background-repeat: repeat-x; background-size: 80px var(--oyu-h); flex-shrink: 0; }
.mc-body { flex: 1; padding: 22px 18px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.mc-icon { font-size: 2.4rem; }
.ai-icon { color: var(--red); }
.pvp-icon { color: var(--cobalt); }
.mc-name { font-family: 'Cinzel Decorative', serif; font-size: 1rem; color: var(--text); }
.mc-desc { font-size: .72rem; color: var(--text-m); line-height: 1.65; font-family: 'Lora', serif; max-width: 200px; }
.mc-tag {
  font-size: .58rem; letter-spacing: .14em; text-transform: uppercase;
  background: rgba(139,26,26,0.08); border: 1px solid rgba(139,26,26,0.25);
  color: var(--red); border-radius: 20px; padding: 3px 11px;
}
.blue-tag { background: rgba(27,67,114,0.08); border-color: rgba(27,67,114,0.25); color: var(--cobalt); }
.mc-btn { margin-top: 4px; }

.lobby-stats { display: flex; align-items: center; gap: 7px; font-size: .7rem; color: var(--text-m); font-family: 'Lora', serif; }
.online-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
.stat-sep { opacity: .4; }

/* ══════════════════════════════════════════
   SCREEN: ROOMS
══════════════════════════════════════════ */
#screen-rooms { overflow-y: auto; }
.rooms-body {
  flex: 1; padding: 16px 20px; max-width: 820px; width: 100%; margin: 0 auto;
  display: flex; flex-direction: column; gap: 14px;
  background-image: var(--bg-pattern); background-size: 80px 80px;
  background-color: var(--cream);
}
.qa-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qa-card {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  background: #fff; border: 2px solid var(--red); border-radius: 11px;
  text-align: left; transition: all var(--t);
  box-shadow: 0 3px 10px rgba(139,26,26,0.1);
}
.qa-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(139,26,26,0.18); }
.qa-blue { border-color: var(--cobalt); }
.qa-blue:hover { box-shadow: 0 8px 24px rgba(27,67,114,0.18); }
.qa-ico { font-size: 1.5rem; }
.qa-name { font-size: .82rem; color: var(--text); font-weight: 600; font-family: 'Cinzel', serif; }
.qa-hint { font-size: .66rem; color: var(--text-m); margin-top: 2px; font-family: 'Lora', serif; }

.rooms-panel { background: #fff; border: 2px solid var(--red); border-radius: 11px; overflow: hidden; }
.rooms-head { display: flex; align-items: center; justify-content: space-between; padding: 11px 15px; border-bottom: 1px solid var(--cream-dd); }
.rooms-head h3 { font-size: .8rem; color: var(--red); letter-spacing: .07em; }
.btn-refresh { color: var(--text-m); font-size: 1rem; transition: all var(--t); padding: 4px 8px; border-radius: 4px; }
.btn-refresh:hover { color: var(--red); transform: rotate(180deg); }
.rooms-list { max-height: 360px; overflow-y: auto; padding: 8px; }
.rooms-empty { display: flex; flex-direction: column; align-items: center; padding: 40px 20px; gap: 8px; }
.rooms-empty p { font-size: .78rem; color: var(--text-m); font-family: 'Lora', serif; font-style: italic; }
.room-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-radius: 8px; border: 1.5px solid var(--cream-dd);
  margin-bottom: 6px; background: var(--cream); transition: all var(--t);
}
.room-item:hover { border-color: var(--red); background: #fff; }
.ri-name { font-size: .82rem; color: var(--text); font-weight: 600; }
.ri-meta { font-size: .66rem; color: var(--text-m); margin-top: 2px; font-family: 'Lora', serif; }
.btn-join {
  padding: 6px 14px; background: var(--red); color: var(--cream); border-radius: 6px;
  font-size: .72rem; letter-spacing: .04em; font-family: 'Cinzel', serif;
  transition: all var(--t); flex-shrink: 0;
}
.btn-join:hover { background: var(--red-l); transform: translateY(-1px); }

/* Quick match */
.qm-spinner { position: relative; width: 64px; height: 64px; margin: 0 auto 16px; }
.qm-r { position: absolute; inset: 0; border-radius: 50%; border: 2.5px solid transparent; }
.qm-r.r1 { border-top-color: var(--red); border-right-color: var(--gold); animation: spinR .9s linear infinite; }
.qm-r.r2 { inset: 10px; border-bottom-color: var(--cobalt); animation: spinR 1.3s linear infinite reverse; }
@keyframes spinR { to { transform: rotate(360deg); } }
.qm-core { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; color: var(--gold); }

/* Rules modal */
.rules-box { max-width: 500px; }
.rules-box .modal-inner { padding: 24px 28px 20px; }
.rules-list { display: flex; flex-direction: column; gap: 8px; }
.rule-item {
  display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px;
  background: var(--cream); border: 1px solid var(--border); border-radius: 8px; transition: background var(--t);
}
.rule-item:hover { background: var(--cream-d); }
.rule-num { font-family: 'Cinzel Decorative', serif; color: var(--red); font-size: .85rem; flex-shrink: 0; line-height: 1.5; }
.rule-txt { font-size: .78rem; color: var(--text-m); line-height: 1.65; font-family: 'Lora', serif; }

/* ══════════════════════════════════════════
   SCREEN: WAITING ROOM
══════════════════════════════════════════ */
#screen-waiting { overflow: hidden; }
.waiting-body { flex: 1; display: grid; grid-template-columns: 320px 1fr; overflow: hidden; background: var(--cream); background-image: var(--bg-pattern); background-size: 80px 80px; }
.w-left { padding: 16px; overflow-y: auto; border-right: 2px solid var(--border); }
.w-right { display: flex; flex-direction: column; overflow: hidden; }
.w-card { background: #fff; border: 2px solid var(--red); border-radius: 12px; overflow: hidden; }
.w-card-inner { padding: 18px; }
.w-card-title { font-size: .78rem; color: var(--red); letter-spacing: .08em; text-transform: uppercase; display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.w-count { font-size: .65em; color: var(--text-m); font-weight: 400; }
.w-slots { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.w-slot {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--cream); border: 1.5px solid var(--border); border-radius: 9px;
}
.w-empty { border-style: dashed; opacity: .6; }
.w-av {
  width: 34px; height: 34px; border-radius: 50%; background: var(--red); color: var(--cream);
  display: flex; align-items: center; justify-content: center; font-size: .85rem; font-weight: 700; flex-shrink: 0;
}
.empty-av { background: var(--cream-dd); color: var(--text-m); }
.w-name { font-size: .8rem; color: var(--text); font-weight: 600; }
.w-role { font-size: .62rem; color: var(--text-m); text-transform: uppercase; letter-spacing: .07em; margin-top: 2px; }
.w-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cream-dd); margin-left: auto; flex-shrink: 0; }
.w-dot.ready { background: var(--green); box-shadow: 0 0 6px rgba(45,96,64,.4); animation: pulse 2s infinite; }
.w-vs { text-align: center; font-size: .75rem; color: var(--text-l); }
.room-info { border-top: 1px solid var(--cream-dd); padding-top: 12px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 7px; }
.ri { display: flex; justify-content: space-between; font-size: .75rem; font-family: 'Lora', serif; }
.ri span { color: var(--text-m); }
.ri strong { color: var(--text); }
.copy-code { cursor: pointer; color: var(--red) !important; text-decoration: underline dashed; font-family: 'Cinzel', serif; letter-spacing: .1em; }
.s-wait { color: #c08000 !important; }
.s-ready { color: var(--green) !important; }
.btn-start { border-radius: 8px; }
.wait-hint { text-align: center; font-size: .7rem; color: var(--text-m); padding: 8px 0 4px; font-family: 'Lora', serif; font-style: italic; }

/* ══════════════════════════════════════════
   CHAT
══════════════════════════════════════════ */
.chat-panel, .chat-col { display: flex; flex-direction: column; overflow: hidden; background: var(--cream); }
.chat-hdr {
  display: flex; align-items: center; gap: 7px; padding: 10px 14px;
  border-bottom: 2px solid var(--border); font-size: .72rem; color: var(--text-m);
  letter-spacing: .06em; flex-shrink: 0; background: rgba(139,26,26,0.05);
}
.chat-collapse { margin-left: auto; color: var(--text-l); transition: color var(--t); padding: 2px 5px; }
.chat-collapse:hover { color: var(--red); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 7px; }
.chat-row { display: flex; gap: 7px; padding: 8px 10px; border-top: 1.5px solid var(--border); flex-shrink: 0; background: #fff; }
.chat-input {
  flex: 1; background: var(--cream); border: 1.5px solid var(--cream-dd); border-radius: 7px;
  color: var(--text); padding: 8px 11px; font-size: .8rem; transition: border-color var(--t);
  font-family: 'Lora', serif;
}
.chat-input:focus { border-color: var(--red); }
.chat-send {
  width: 34px; height: 34px; border-radius: 7px; background: var(--red);
  color: #fff; font-size: 1rem; flex-shrink: 0; transition: all var(--t);
}
.chat-send:hover { background: var(--red-l); }
.chat-bubble { max-width: 100%; }
.cb-hdr { display: flex; align-items: baseline; gap: 6px; margin-bottom: 2px; }
.cb-name { font-size: .65rem; color: var(--red); font-weight: 700; font-family: 'Cinzel', serif; }
.cb-self .cb-name { color: var(--cobalt); }
.cb-time { font-size: .58rem; color: var(--text-l); }
.cb-txt { font-size: .78rem; color: var(--text); line-height: 1.5; font-family: 'Lora', serif; word-break: break-word; }
.chat-sys { font-size: .68rem; color: var(--text-l); text-align: center; font-style: italic; font-family: 'Lora', serif; padding: 2px 0; }

/* ══════════════════════════════════════════
   GAME BAR
══════════════════════════════════════════ */
.game-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; padding-right: 210px;
  background: var(--red); flex-shrink: 0; gap: 10px;
}
.gb-player { display: flex; align-items: center; gap: 8px; flex: 1; }
.gb-right { flex-direction: row-reverse; }
.gb-av {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; border: 2px solid rgba(255,255,255,0.3); flex-shrink: 0;
  background: rgba(255,255,255,0.15);
}
.ai-av { color: var(--gold-l); }
.human-av { color: #fff; }
.gb-name { font-size: .78rem; color: rgba(255,255,255,0.9); font-weight: 600; }
.gb-score { display: flex; align-items: baseline; gap: 3px; }
.gb-score span:first-child { font-family: 'Cinzel Decorative', serif; font-size: 1.1rem; color: var(--gold-l); }
.gb-pts { font-size: .58rem; color: rgba(255,255,255,0.6); }
.right-info { text-align: right; }
.gb-center { display: flex; flex-direction: column; align-items: center; gap: 5px; flex-shrink: 0; }
.turn-pill {
  padding: 4px 14px; border-radius: 20px; font-size: .62rem; letter-spacing: .1em;
  text-transform: uppercase; background: var(--gold); color: var(--red); font-weight: 700;
  white-space: nowrap; transition: background var(--t), color var(--t);
}
.turn-pill.ai-turn { background: var(--cobalt); color: #fff; }
.btn-quit { font-size: .62rem; color: rgba(255,255,255,0.6); letter-spacing: .04em; padding: 3px 8px; border-radius: 4px; transition: color var(--t); }
.btn-quit:hover { color: var(--gold-l); }
.gb-pip { width: 6px; height: 6px; border-radius: 50%; background: transparent; flex-shrink: 0; transition: background .3s; }
.gb-pip.active { background: var(--gold); box-shadow: 0 0 6px rgba(201,168,76,.6); animation: pipPulse 1.2s infinite; }
@keyframes pipPulse { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ══════════════════════════════════════════
   GAME LAYOUT
══════════════════════════════════════════ */
.game-layout { flex: 1; display: grid; grid-template-columns: 1fr 270px; overflow: hidden; background: var(--cream); background-image: var(--bg-pattern); background-size: 80px 80px; }
.board-col { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 10px 14px; gap: 7px; overflow: auto; }
.chat-col { border-left: 2px solid var(--border); display: flex; flex-direction: column; background: var(--cream); }
.chat-col.collapsed { display: none; }

/* Kazhan */
.kazhan-bar {
  display: flex; align-items: center; gap: 10px; width: 100%; max-width: 680px;
  background: #fff; border: 2px solid var(--border); border-radius: 9px; padding: 7px 12px;
}
.kz-lbl { font-size: .58rem; letter-spacing: .15em; text-transform: uppercase; color: var(--text-m); flex-shrink: 0; min-width: 52px; font-family: 'Cinzel', serif; }
.kz-stones { display: flex; flex-wrap: wrap; gap: 2px; flex: 1; min-height: 14px; }
.kz-stone { width: 9px; height: 9px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #ddd 50%, #bbb); box-shadow: 1px 1px 2px rgba(0,0,0,.25); animation: popIn .15s ease-out; }
.kz-num { font-family: 'Cinzel Decorative', serif; font-size: .9rem; color: var(--red); flex-shrink: 0; min-width: 26px; text-align: right; }
@keyframes popIn { from{transform:scale(0);opacity:0} to{transform:none;opacity:1} }

/* Board */
.board {
  position: relative; width: 100%; max-width: 680px;
  background: var(--board-bg);
  border: 3px solid var(--gold-d); border-radius: 18px; overflow: hidden;
  box-shadow: 0 0 0 1px rgba(201,168,76,0.3), 0 16px 50px rgba(60,20,5,.35), inset 0 1px 0 rgba(255,255,255,0.15);
}
.board-inner { padding: 12px 10px; }
.board-oyu { height: var(--oyu-h); }
.board-row { display: flex; justify-content: center; gap: 7px; padding: 6px 0; }
.ai-holes { flex-direction: row-reverse; }
.board-divider { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.bd-line { flex: 1; height: 1.5px; background: linear-gradient(90deg, transparent, rgba(201,168,76,0.5), transparent); }
.bd-gem { color: var(--gold); font-size: .75rem; }

/* Holes */
.hole {
  width: clamp(50px,6.5vw,66px); height: clamp(86px,10.5vw,110px);
  background: radial-gradient(ellipse at center 20%, #3A200A, #1E0C04);
  border-radius: 10px; display: flex; flex-direction: column; align-items: center;
  justify-content: flex-end; padding: 5px 4px; position: relative;
  border: 2px solid rgba(201,168,76,0.2);
  box-shadow: inset 0 4px 14px rgba(0,0,0,.65), inset 0 -1px 4px rgba(201,168,76,0.08);
  overflow: hidden; transition: border-color var(--t), transform var(--t), box-shadow var(--t);
}
.ai-holes .hole { justify-content: flex-start; }
.hole.clickable { cursor: pointer; border-color: rgba(201,168,76,0.45); }
.hole.clickable:hover {
  border-color: var(--gold); transform: translateY(-4px);
  box-shadow: inset 0 4px 14px rgba(0,0,0,.5), 0 0 16px rgba(201,168,76,0.2), 0 8px 14px rgba(0,0,0,.3);
}
.hole.flash { animation: holeFlash .4s ease-out; }
@keyframes holeFlash { 0%{border-color:var(--gold-l);box-shadow:0 0 20px rgba(201,168,76,.5)} 100%{} }
.stones-wrap { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; width: 100%; padding: 1px; }
.ai-holes .stones-wrap { align-content: flex-start; }
.player-holes .stones-wrap { align-content: flex-end; }
.stone {
  width: clamp(7px,1vw,11px); height: clamp(7px,1vw,11px); border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #e8e0d0 40%, #c0b090);
  box-shadow: 1px 1px 2px rgba(0,0,0,.4), inset 0 -1px 1px rgba(0,0,0,.15), inset 1px 1px 1px rgba(255,255,255,.5);
  flex-shrink: 0;
}
.hole-count { position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%); font-size: .6rem; color: rgba(201,168,76,0.8); font-weight: 700; z-index: 2; font-family: 'Cinzel', serif; }

/* Win Overlay */
.win-overlay {
  display: none; position: absolute; inset: 0; z-index: 100;
  background: rgba(60,20,5,0.72); backdrop-filter: blur(6px);
  align-items: center; justify-content: center;
}
.win-overlay.show { display: flex; animation: fadeIn .3s; }
.win-card {
  background: #fff; border: 3px solid var(--red); border-radius: 16px; overflow: hidden;
  width: 90%; max-width: 380px; box-shadow: 0 30px 80px rgba(60,20,5,.5);
  animation: slideUp .35s cubic-bezier(.34,1.56,.64,1);
}
.win-inner { padding: 28px 32px; text-align: center; }
.win-ornament { font-size: 1.4rem; color: var(--gold); margin-bottom: 8px; }
.win-emoji { font-size: 2.8rem; margin-bottom: 8px; animation: bounceIn .5s cubic-bezier(.34,1.56,.64,1) .2s both; }
.win-title { font-family: 'Cinzel Decorative', serif; font-size: 1.3rem; color: var(--red); margin-bottom: 24px; }
.win-scores { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 16px; background: var(--cream); border-radius: 10px; margin-bottom: 22px; }
.ws { text-align: center; }
.ws-name { font-size: .62rem; letter-spacing: .14em; color: var(--text-m); text-transform: uppercase; margin-bottom: 4px; font-family: 'Cinzel', serif; }
.ws-val { font-family: 'Cinzel Decorative', serif; font-size: 2rem; color: var(--red); line-height: 1; }
.ws-vs { font-size: .7rem; color: var(--text-l); }

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */
@media(max-width:860px) {
  .top-bar,.game-bar{padding-right:14px}
  .game-layout{grid-template-columns:1fr}
  .chat-col{position:fixed;bottom:0;left:0;right:0;height:200px;border-top:2px solid var(--border);border-left:none;z-index:20}
  .board-col{padding-bottom:210px}
  .waiting-body{grid-template-columns:1fr;overflow-y:auto}
  .w-left{border-right:none;border-bottom:2px solid var(--border)}
  .w-right{height:240px;flex-shrink:0}
  .mode-cards{flex-direction:column}
  .mode-sep{flex-direction:row;padding:8px 0}
  .sep-line{width:40px;height:1px}
  .qa-grid{grid-template-columns:1fr}
}
@media(max-width:500px) {
  .hole{width:40px;height:68px}
  .board-inner{padding:8px 6px}
  .board-row{gap:5px}
  .cbox{width:36px;height:44px;font-size:1.1rem}
  .code-row{gap:5px}
}
*::-webkit-scrollbar{width:4px;height:4px}
*::-webkit-scrollbar-track{background:var(--cream-d)}
*::-webkit-scrollbar-thumb{background:rgba(139,26,26,0.3);border-radius:2px}
*::-webkit-scrollbar-thumb:hover{background:var(--red)}
