*{box-sizing:border-box}
:root{--bg:#0f1419;--line:#1e2a36}
html{font-size:16px}
html,body{margin:0;min-height:100%;background:var(--bg);color:#e6edf3;font-family:"Be Vietnam Pro",system-ui,sans-serif;overflow:hidden;-webkit-tap-highlight-color:transparent}
.map-scroll{position:relative;width:100vw;height:100vh;overflow:hidden;background:radial-gradient(900px 500px at 50% 0%, #1a2430, #0f1419);display:block;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;scrollbar-width:none;-ms-overflow-style:none;user-select:none}
.map-scroll::-webkit-scrollbar{display:none;width:0;height:0}
.map-scroll.dragging{cursor:grabbing}
#board{position:absolute;top:0;left:0;transform-origin:0 0;background:transparent;touch-action:none;image-rendering:auto;will-change:transform}

/* setup riêng - responsive */
.setup-screen{position:fixed;inset:0;background:rgba(10,14,19,0.96);backdrop-filter:blur(10px);display:grid;place-items:center;z-index:40;padding:16px;overflow:auto}
.setup-box{background:#121a23;border:1px solid var(--line);border-radius:16px;padding:22px;max-width:520px;width:100%;text-align:center;box-shadow:0 12px 40px rgba(0,0,0,.5);margin:auto}
.setup-box h1{margin:0;font-size:clamp(18px,4vw,24px);letter-spacing:.1em}
.setup-sub{color:#8ea0b5;font-size:clamp(11px,2.5vw,13px);margin:6px 0 14px;line-height:1.4}
.setup-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin-bottom:14px;text-align:left}
.setup-grid label{font-size:12px;color:#cbd5e1;display:flex;flex-direction:column;gap:6px}
.setup-grid select{background:#0f1419;color:#e6edf3;border:1px solid var(--line);border-radius:8px;padding:10px;font-size:14px;min-height:42px}
.btn-start{width:100%;padding:14px;border:0;border-radius:10px;background:linear-gradient(135deg,#22c55e,#16a34a);color:#fff;font-weight:800;letter-spacing:.06em;cursor:pointer;font-size:15px;min-height:48px}
.btn-start:disabled{opacity:.5;cursor:not-allowed}
.setup-hint{font-size:11px;color:#6b7f95;margin-top:10px;line-height:1.4}
.mode-tabs{display:flex;gap:8px;margin-bottom:14px}
.mode-btn{flex:1;padding:10px;border:1px solid var(--line);background:#0f1419;color:#cbd5e1;border-radius:8px;cursor:pointer;font-weight:700;font-size:13px}
.mode-btn.active{background:#22c55e;color:#fff;border-color:#22c55e}
.mode-panel{margin-bottom:12px}
.bot-selection{margin:10px 0;padding:10px;background:#0f1419;border:1px solid var(--line);border-radius:8px}
.bot-selection h4{margin:0 0 8px;font-size:13px;color:#cbd5e1}
.bot-slots{display:flex;gap:8px;flex-wrap:wrap}
.bot-slot{flex:1;min-width:100px;padding:8px;background:#1a1a2e;border:2px solid var(--line);border-radius:8px;display:flex;flex-direction:column;gap:4px;transition:border-color .2s}
.bot-slot.bot{border-color:#facc15;background:#1a1500}
.bot-slot-label{font-size:12px;font-weight:700;color:#cbd5e1}
.btn-slot{margin-left:8px;padding:8px 14px;border:1px solid var(--line);background:#0f1419;color:#cbd5e1;border-radius:8px;cursor:pointer;font-size:13px;font-weight:700;min-height:36px}
.btn-slot.bot-active{background:#3a2a04;border-color:#f59e0b;color:#fde68a}

.bot-slot-select{background:#0f1419;color:#e6edf3;border:1px solid var(--line);border-radius:6px;padding:6px;font-size:13px}
.btn-start{width:100%;padding:14px;border:0;border-radius:10px;background:linear-gradient(135deg,#22c55e,#16a34a);color:#fff;font-weight:800;letter-spacing:.06em;cursor:pointer;font-size:15px;min-height:48px}
.btn-start:disabled{opacity:.5;cursor:not-allowed}
.setup-hint{font-size:11px;color:#6b7f95;margin-top:10px;line-height:1.4}
.mode-tabs{display:flex;gap:8px;margin-bottom:14px}
.mode-btn{flex:1;padding:10px;border:1px solid var(--line);background:#0f1419;color:#cbd5e1;border-radius:8px;cursor:pointer;font-weight:700;font-size:13px}
.mode-btn.active{background:#22c55e;color:#fff;border-color:#22c55e}
.mode-panel{margin-bottom:12px}
.room-code{font-size:22px;letter-spacing:.18em;color:#facc15;background:#1a1500;padding:6px 10px;border-radius:8px;border:1px dashed #facc15}
.host-status{font-size:12px;color:#94a3b8;margin:8px 0}
.host-players{display:flex;gap:6px;flex-wrap:wrap;justify-content:center;margin:8px 0}
.join-input{width:100%;padding:12px;border:1px solid var(--line);background:#0f1419;color:#e6edf3;border-radius:8px;font-size:18px;letter-spacing:.15em;text-align:center;text-transform:uppercase;margin-bottom:10px}
.online-status{font-size:11px;color:#22c55e;margin-top:8px;word-break:break-all}

/* player info tách riêng */
.player-info-panel{position:fixed;left:16px;top:16px;background:rgba(18,26,35,0.96);border:1px solid var(--line);border-radius:12px;padding:10px;z-index:20;min-width:180px;max-width:260px;box-shadow:0 8px 24px rgba(0,0,0,.4);max-height:40vh;overflow:auto}
.player-info-list{display:flex;flex-direction:column;gap:6px}
.player-info-row{display:flex;align-items:center;gap:8px;padding:6px 8px;border-radius:8px;background:#0f1419;border:1px solid var(--line);font-size:12px}
.player-info-row.active{border-color:#22c55e;background:#122a1a}
.player-info-dot{width:10px;height:10px;border-radius:50%;flex:0 0 10px}
.player-info-name{flex:1;font-weight:700}
.player-info-stats{display:flex;gap:8px;font-size:11px;color:#8ea0b5}
.player-info-stats span{display:flex;align-items:center;gap:2px}

/* dice tách riêng to góc - responsive */
.dice-panel{position:fixed;right:16px;bottom:16px;background:rgba(18,26,35,0.96);border:1px solid var(--line);border-radius:14px;padding:12px;z-index:20;min-width:160px;max-width:92vw;box-shadow:0 8px 24px rgba(0,0,0,.4);display:flex;flex-direction:column;gap:8px;align-items:center}
.dice-head{display:flex;align-items:center;gap:6px;font-size:12px;font-weight:700;color:#cbd5e1;width:100%}
.turn-dot{width:10px;height:10px;border-radius:50%;background:#22c55e;border:2px solid #fff3;flex:0 0 10px}
.lap-mini{margin-left:auto;color:#8ea0b5}
.dice-big{width:72px;height:72px;border-radius:12px;background:#fff;color:#111;display:grid;place-items:center;font-size:32px;font-weight:800;flex:0 0 72px}
.dice-big.rolling{animation:shake .32s infinite}
@keyframes shake{0%,100%{transform:rotate(0)}25%{transform:rotate(-7deg)}75%{transform:rotate(7deg)}}
.btn-roll-big{width:100%;padding:12px;border:0;border-radius:10px;background:linear-gradient(135deg,#22c55e,#16a34a);color:#fff;font-weight:800;font-size:15px;cursor:pointer;letter-spacing:.06em;min-height:44px}
.btn-roll-big:disabled{opacity:.5}
.msg-mini{font-size:11px;color:#94a3b8;min-height:14px;text-align:center;word-break:break-word}
.btn-reset-mini{background:#0f1419;border:1px solid var(--line);color:#8ea0b5;border-radius:8px;padding:8px;font-size:11px;cursor:pointer;width:100%;min-height:36px}

/* fork & horse tách riêng to giữa - responsive */
.fork-panel{position:fixed;left:50%;top:50%;transform:translate(-50%,-50%);background:#0c1a12;border:2px solid #22c55e;border-radius:16px;padding:18px;z-index:30;min-width:320px;max-width:min(90vw,520px);max-height:80vh;overflow:auto;box-shadow:0 16px 40px rgba(0,0,0,.6);text-align:center}
#horsePanel{border-color:#facc15;background:#1a1500}
#horsePanel h3{color:#facc15}
#btnBuyFlag{background:linear-gradient(135deg,#facc15,#eab308) !important;color:#111 !important;border-color:#facc15 !important}
#btnSkipHorse{background:#334155 !important;color:#cbd5e1 !important;border-color:#334155 !important}
.fork-panel h3{margin:0;font-size:clamp(14px,3.5vw,18px);letter-spacing:.06em;color:#86efac}
.fork-hint{font-size:11px;color:#6b8a72;margin:6px 0 12px}
.fork-btns-big{display:flex;gap:12px;justify-content:center;flex-wrap:wrap}
.fork-btns-big button{padding:14px 18px;border-radius:10px;border:2px solid #22c55e;background:#132a1c;color:#bbf7d0;cursor:pointer;font-size:15px;font-weight:800;min-width:120px;min-height:44px;flex:1 1 140px;max-width:220px}

.modal{position:fixed;inset:0;background:rgba(0,0,0,.55);backdrop-filter:blur(6px);display:grid;place-items:center;z-index:50;padding:16px}
.hidden{display:none !important}
.box{background:#121a23;border:1px solid var(--line);padding:20px;border-radius:12px;text-align:center;min-width:280px;max-width:90vw;width:400px}
.box h2{margin:0 0 8px;font-size:clamp(18px,4vw,22px)}

/* Responsive breakpoints */
@media(max-width:1024px){
  .map-scroll{height:100vh}
  .setup-box{max-width:480px}
}
@media(max-width:768px){
  html{font-size:15px}
  .setup-screen{padding:12px;align-items:start;overflow:auto}
  .setup-box{margin:20px auto;padding:18px;max-width:92vw}
  .setup-grid{grid-template-columns:1fr 1fr;gap:10px}
  .player-info-panel{left:8px;right:8px;top:8px;max-width:none;max-height:32vh}
  .dice-panel{right:8px;left:8px;bottom:8px;min-width:0;max-width:none;width:auto;flex-direction:row;flex-wrap:wrap;justify-content:space-between;padding:10px;gap:8px}
  .dice-head{width:auto;flex:1 1 100px}
  .dice-big{width:56px;height:56px;flex:0 0 56px;font-size:24px}
  .btn-roll-big{flex:1 1 120px;min-width:100px}
  .msg-mini{flex:1 1 100%;order:5}
  .btn-reset-mini{flex:0 0 70px;width:auto}
  .fork-panel{top:auto;bottom:0;left:0;right:0;transform:none;border-radius:16px 16px 0 0;min-width:0;max-width:100vw;max-height:60vh;padding:16px 12px 20px}
  .fork-btns-big button{flex:1 1 45%;min-width:0;padding:16px 12px;font-size:14px}
}
@media(max-width:480px){
  html{font-size:14px}
  .setup-box h1{font-size:20px}
  .setup-grid{grid-template-columns:1fr;gap:12px}
  .setup-grid select{padding:12px;font-size:15px}
  .btn-start{padding:16px;font-size:16px}
  .dice-panel{right:6px;left:6px;bottom:6px;padding:8px;gap:6px}
  .dice-big{width:48px;height:48px;flex:0 0 48px;font-size:20px;border-radius:8px}
  .btn-roll-big{padding:10px;font-size:14px}
  .fork-panel{padding:12px 10px 16px}
  .fork-btns-big{gap:8px}
  .fork-btns-big button{padding:14px 10px;font-size:13px}
  .box{padding:16px;min-width:0;width:92vw}
}
@media(max-width:360px){
  .dice-panel{flex-direction:column;align-items:stretch}
  .dice-head{justify-content:center}
  .dice-big{align-self:center}
}
@media(min-width:1600px){
  .setup-box{max-width:560px;padding:28px}
  .dice-panel{min-width:180px;padding:14px}
  .dice-big{width:80px;height:80px;flex:0 0 80px;font-size:36px}
}

/* Landscape phone */
@media(max-height:500px) and (orientation:landscape){
  .setup-screen{place-items:start center;overflow:auto}
  .setup-box{margin:10px auto}
  .dice-panel{right:8px;bottom:4px;top:auto;flex-direction:row;max-height:90vh;overflow:auto}
  .fork-panel{max-height:85vh}
}

/* High DPI */
@media(-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){
  #board{image-rendering:-webkit-optimize-contrast}
}
