* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #02030a; color: #e8ecff; font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#panel { position: fixed; top: 12px; left: 12px; width: 300px; padding: 14px; border-radius: 14px;
  background: rgba(10, 14, 34, 0.72); backdrop-filter: blur(8px); border: 1px solid rgba(140, 170, 255, 0.25);
  box-shadow: 0 8px 30px rgba(0,0,0,0.45); font-size: 13px; z-index: 5; }
.title { font-size: 22px; font-weight: 700; letter-spacing: 0.5px; }
.sub { font-size: 12px; font-weight: 400; opacity: 0.7; margin-left: 6px; }
.status { margin: 8px 0 4px; font-size: 15px; font-weight: 600; min-height: 20px; }
.status.check { color: #ff7a7a; text-shadow: 0 0 10px rgba(255,80,80,0.7); }
.poles { font-size: 12px; opacity: 0.8; margin-bottom: 8px; }
.grid { display: grid; gap: 6px; }
label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; opacity: 0.95; }
label.chk { flex-direction: row; align-items: center; gap: 6px; margin-top: 6px; }
select, button { font: inherit; color: #e8ecff; background: rgba(40, 52, 100, 0.8); border: 1px solid rgba(150, 180, 255, 0.35);
  border-radius: 8px; padding: 6px 8px; }
button { cursor: pointer; }
button:hover { background: rgba(70, 90, 170, 0.9); }
.row { display: flex; gap: 6px; margin-top: 10px; }
.row button { flex: 1; }
.hint { margin-top: 10px; font-size: 11px; opacity: 0.7; line-height: 1.4; }
#movesPanel { position: fixed; top: 12px; right: 12px; width: 190px; max-height: 34vh; overflow: auto; padding: 10px 12px;
  border-radius: 14px; background: rgba(10, 14, 34, 0.72); border: 1px solid rgba(140,170,255,0.25); backdrop-filter: blur(8px); z-index: 5; }
.mtitle { font-weight: 700; margin-bottom: 6px; }
#moves { margin: 0; padding-left: 26px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; line-height: 1.6; }
#moves li span { display: inline-block; min-width: 64px; }
#moves .last { color: #ffd479; }
#menuBtn { display: none; position: fixed; top: 10px; left: 10px; z-index: 6; font-size: 20px; padding: 4px 10px; }

.promoBox { background: rgba(14,20,48,0.95); padding: 16px; border-radius: 14px; border: 1px solid rgba(150,180,255,0.4); text-align: center; }
.promoRow { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; justify-content: center; }
.promoRow button { font-size: 16px; padding: 10px 12px; }
#banner { position: fixed; left: 50%; top: 14%; transform: translateX(-50%); padding: 12px 22px; border-radius: 14px; font-size: 22px; font-weight: 700;
  background: rgba(14,20,48,0.85); border: 1px solid rgba(255,212,121,0.6); box-shadow: 0 0 30px rgba(255,212,121,0.35); z-index: 8; pointer-events: none; }
.hidden { display: none !important; }
@media (max-width: 720px) {
  #menuBtn { display: block; }
  #panel { top: 52px; width: calc(100% - 24px); max-height: 70vh; overflow: auto; }
  #panel.collapsed { display: none; }
  #movesPanel { top: auto; bottom: 10px; right: 10px; left: 10px; width: auto; max-height: 22vh; }
  #moves { display: flex; flex-wrap: wrap; gap: 0 14px; }
}
.tabs { display: flex; gap: 4px; margin: 8px 0; }
.tab { flex: 1; padding: 5px 4px; font-size: 12px; background: rgba(30,40,80,0.6); }
.tab.on { background: rgba(90,120,220,0.9); }
.accent { background: rgba(40,140,110,0.85); }
.clocks { display: flex; justify-content: space-between; font-size: 13px; margin: 4px 0; }
.clocks b { font-family: ui-monospace, Consolas, monospace; font-size: 16px; padding: 2px 6px; border-radius: 6px; }
.clocks b.on { background: rgba(255,212,121,0.25); color: #ffe3a8; }
.list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.list button { text-align: left; }
.list small { display: block; opacity: 0.75; font-family: ui-monospace, Consolas, monospace; }
.coach { margin-top: 10px; font-size: 12px; line-height: 1.45; color: #cfe8ff; min-height: 0; }
.coach:empty { display: none; }
#panel { max-height: calc(100vh - 24px); overflow: auto; }
#moves .mv { cursor: pointer; border-radius: 4px; padding: 0 3px; }
#moves .mv:hover { background: rgba(120,150,255,0.25); }
#reviewBar { margin-top: 6px; }
#mapPanel { position: fixed; right: 12px; bottom: 12px; padding: 6px; border-radius: 12px; background: rgba(10,14,34,0.72); border: 1px solid rgba(140,170,255,0.25); z-index: 5; }
#mapCanvas { display: block; cursor: pointer; border-radius: 6px; }
#exposeBar { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; gap: 8px; align-items: center; max-width: min(620px, 92vw);
  padding: 8px 10px; border-radius: 12px; background: rgba(10,14,34,0.82); border: 1px solid rgba(255,192,64,0.45); font-size: 13px; z-index: 6; }
#tutorBox { position: fixed; left: 50%; top: 12px; transform: translateX(-50%); width: min(520px, 92vw); padding: 12px 14px; border-radius: 14px;
  background: rgba(14,20,48,0.9); border: 1px solid rgba(255,212,121,0.5); z-index: 7; font-size: 13px; line-height: 1.5; }
.ttop { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.45); z-index: 10; }
.promoBox.wide { width: min(560px, 92vw); }
textarea { width: 100%; margin-top: 8px; background: #0b1024; color: #e8ecff; border: 1px solid rgba(150,180,255,0.35); border-radius: 8px; font-family: ui-monospace, Consolas, monospace; }
#dialogText { max-width: 420px; line-height: 1.5; }
@media (max-width: 720px) {
  #mapPanel { bottom: auto; top: 52px; right: 10px; }
  #movesPanel { max-height: 16vh; }
  #exposeBar { bottom: 18vh; }
  #tutorBox { top: auto; bottom: 18vh; }
}
#legendBox { position: fixed; left: 12px; bottom: 12px; padding: 8px 10px; border-radius: 12px; background: rgba(10,14,34,0.72); border: 1px solid rgba(140,170,255,0.25);
  font-size: 11px; z-index: 5; display: grid; grid-template-columns: 1fr 1fr; gap: 3px 12px; max-width: 360px; }
#legendBox .lgTitle { grid-column: 1 / -1; font-weight: 700; font-size: 12px; margin-bottom: 2px; }
#legendBox .lg { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
#legendBox i { display: inline-block; width: 26px; height: 6px; border-radius: 3px; box-shadow: 0 0 6px rgba(255,255,255,0.35); }
#guideTip { position: fixed; left: 50%; top: 10px; transform: translateX(-50%); font-size: 13px; padding: 4px 10px; border-radius: 10px; background: rgba(10,14,34,0.6); z-index: 6; pointer-events: none; }
#guideTip:empty { display: none; }
#bubble { position: fixed; left: 0; top: 0; max-width: min(280px, 70vw); padding: 9px 12px; border-radius: 14px 14px 14px 4px; font-size: 13px; line-height: 1.45;
  color: #fff6e3; background: rgba(36, 24, 8, 0.82); border: 1px solid rgba(201,147,42,0.7); box-shadow: 0 0 18px rgba(201,147,42,0.35); z-index: 9; pointer-events: none;
  transition: opacity 0.6s ease; will-change: transform; }
#bubble.fade { opacity: 0; }
#tutorBox { max-height: 42vh; overflow: auto; }
#exposeBar span { flex: 1; min-width: 0; }
.status, .coach, #tutorText, #exposeText { overflow-wrap: anywhere; }
@media (max-width: 720px) {
  #legendBox { display: none; }
  #guideTip { top: auto; bottom: 25vh; }
}
@media (max-height: 640px) {
  #movesPanel { max-height: 24vh; }
  #legendBox { grid-template-columns: 1fr 1fr 1fr 1fr; max-width: 60vw; }
}
.watch { padding: 8px; border-radius: 10px; background: rgba(40,52,100,0.35); border: 1px solid rgba(150,180,255,0.2); margin-bottom: 10px; }
.wtitle { font-weight: 700; font-size: 14px; }
.wgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.wsum { margin-top: 8px; font-size: 12px; line-height: 1.5; }
.wsum:empty { display: none; }
.wsum table { width: 100%; border-collapse: collapse; }
.wsum td { padding: 1px 4px; }
.wsum td:last-child { text-align: right; font-family: ui-monospace, Consolas, monospace; }
.bar { height: 8px; border-radius: 4px; display: flex; overflow: hidden; margin: 4px 0; }
.bar i { display: block; height: 100%; }
@media (min-width: 721px) { body.has-legend #panel { max-height: calc(100vh - 170px); } }

#ratingNow b { font-size: 26px; color: #ffc861; margin-right: 6px; }
#ratingNow .muted { color: #9aa3c0; font-size: 12px; }
#ratingGraph { width: 100%; height: 120px; display: block; margin: 6px 0; background: rgba(0,0,0,0.25); border-radius: 8px; }
table.levels { width: 100%; font-size: 12px; border-collapse: collapse; margin: 4px 0 8px; }
table.levels td { padding: 2px 4px; } table.levels tr.on td { color: #ffc861; font-weight: 600; }

body.view-map #c, body.view-flat #c { inset: auto; right: 12px; bottom: 12px; width: 280px; height: 224px; border-radius: 12px; border: 1px solid rgba(140,170,255,0.35); z-index: 4; }
body.view-flat #c { display: none; }
body.view-map #mapPanel, body.view-flat #mapPanel { left: 50%; top: 50%; right: auto; bottom: auto; transform: translate(-50%, -50%); z-index: 3; }
body.view-flat { background: radial-gradient(ellipse at center, #1a1d3a 0%, #070814 75%); }
@media (max-width: 720px) { body.view-map #c { width: 150px; height: 120px; top: 52px; bottom: auto; right: 8px; }
  body.view-map #mapPanel, body.view-flat #mapPanel { top: 46%; } }
/* Draggable panels */
.floatpanel > .grip { display: flex; align-items: center; gap: 6px; margin: -6px -6px 6px; padding: 3px 6px; cursor: grab; user-select: none; touch-action: none;
  border-radius: 10px 10px 0 0; background: rgba(140,170,255,0.10); font-size: 11px; color: #b8c2e6; }
.floatpanel > .grip:active { cursor: grabbing; }
.floatpanel > .grip .gtitle { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.floatpanel > .grip .gmin { padding: 0 8px; min-width: 26px; line-height: 18px; font-size: 14px; }
.floatpanel.mini { width: auto !important; height: auto !important; max-height: none !important; padding: 4px 6px !important; overflow: hidden; }
.floatpanel.mini > :not(.grip) { display: none !important; }
.floatpanel.mini > .grip { margin: 0; border-radius: 8px; }
#panel.floatpanel > .grip { margin: -14px -14px 8px; border-radius: 14px 14px 0 0; padding: 4px 10px; }
#panel.floatpanel.mini > .grip { margin: 0; }
#coachPanel { position: fixed; left: 50%; bottom: 64px; transform: translateX(-50%); width: min(360px, calc(100vw - 24px)); max-width: calc(100vw - 16px); overflow: auto; padding: 6px; border-radius: 12px; background: rgba(10,14,34,0.78); border: 1px solid rgba(140,170,255,0.25); z-index: 5; font-size: 13px; }
#coachPanel #coachLine:empty::before { content: 'The coach explains moves here.'; color: #7f88a8; }
#bubble .grip { margin: -6px -8px 4px; }
#bubble.floatpanel.mini { opacity: 0.85; }
#legendBox.floatpanel { padding-top: 6px; }
@media (max-width: 720px) { #coachPanel { bottom: 18vh; width: 92vw; } }

#newGameFab { position: fixed; top: 10px; right: 12px; z-index: 7; font-weight: 600; padding: 8px 14px; border-radius: 20px; box-shadow: 0 2px 12px rgba(0,0,0,0.4); }
#movesPanel { top: 54px; }
#newGameBox .ngTitle, #inviteBox .ngTitle, #joinBox .ngTitle { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.ngModes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.ngModes label { display: flex; flex-direction: column; gap: 2px; padding: 10px; border-radius: 10px; border: 1px solid rgba(140,170,255,0.3); cursor: pointer; text-align: left; }
.ngModes label:has(input:checked) { border-color: #ffc861; background: rgba(255,200,97,0.12); }
.ngModes input { display: none; } .ngModes span { font-size: 11px; color: #9aa3c0; }
.ng .grid { margin: 6px 0; } .ng.mode-2p .ng-ai, .ng.mode-online .ng-ai:not(.ng-online) { display: none; }
.invCode { font-size: 14px; margin: 6px 0; } .invCode b { font-size: 24px; letter-spacing: 4px; color: #ffc861; margin-left: 6px; }
#invLink, #joinCode { width: 100%; box-sizing: border-box; padding: 8px; border-radius: 8px; border: 1px solid rgba(140,170,255,0.4); background: rgba(0,0,0,0.3); color: #e8ecff; font-size: 13px; }
#joinCode { font-size: 22px; letter-spacing: 4px; text-transform: uppercase; text-align: center; margin: 8px 0; }
#netStatus { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 7; padding: 5px 12px; border-radius: 16px; background: rgba(10,14,34,0.85); border: 1px solid rgba(140,170,255,0.3); font-size: 12px; display: flex; gap: 6px; align-items: center; }
#netStatus i { width: 9px; height: 9px; border-radius: 50%; background: #888; display: inline-block; }
#netStatus.connected i { background: #4ee08a; box-shadow: 0 0 6px #4ee08a; } #netStatus.waiting i, #netStatus.connecting i, #netStatus.reconnecting i { background: #ffc861; animation: blink 1s infinite; } #netStatus.error i { background: #ff5a5a; }
@keyframes blink { 50% { opacity: 0.3; } }
#onlineBar { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 6; padding: 6px; border-radius: 12px; background: rgba(10,14,34,0.82); border: 1px solid rgba(78,224,138,0.4); }
#onlineBar .row { display: flex; gap: 4px; justify-content: center; margin: 2px 0; }
#emoteToast { position: fixed; top: 46px; left: 50%; transform: translateX(-50%); z-index: 8; padding: 8px 16px; border-radius: 16px; background: rgba(255,200,97,0.92); color: #1a1530; font-size: 18px; font-weight: 600; }
@media (max-width: 720px) { .ngModes { grid-template-columns: 1fr; } #newGameFab { top: 8px; right: 8px; padding: 6px 10px; font-size: 13px; } #netStatus { top: 46px; } #movesPanel { top: auto; } }
#bubble .grip { pointer-events: auto; }
#legendBox > .grip { grid-column: 1 / -1; }

.quickMode { display: grid; grid-template-columns: 1fr; gap: 6px; margin: 6px 0 8px; }
.quickMode label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: #b8c2e6; }
.quickMode select { width: 100%; }

#guideCard { position: fixed; left: 50%; top: 18%; width: min(360px, 88vw); transform: translateX(-50%); z-index: 12; padding: 14px 16px; border-radius: 16px;
  background: linear-gradient(160deg, rgba(48,32,10,0.95), rgba(20,16,40,0.95)); border: 1px solid rgba(255,200,97,0.7); box-shadow: 0 0 28px rgba(255,200,97,0.35); color: #fff6e3; font-size: 14px; line-height: 1.5; }
#guideCard.show { animation: cardIn 0.45s cubic-bezier(.2,.9,.3,1.2); }
@keyframes cardIn { from { opacity: 0; transform: translateX(-50%) translateY(14px) scale(0.92); } to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); } }
#guideCard .cardTop { display: flex; justify-content: space-between; font-size: 12px; color: #ffc861; margin-bottom: 6px; } #guideCard #cardCount { color: #b8a77e; }
#guideCard .row { display: flex; gap: 6px; margin-top: 10px; }
#mapPanel { position: fixed; }
#mapFly { position: absolute; pointer-events: none; }

.floatpanel > .rsz { position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; cursor: nwse-resize; touch-action: none; z-index: 2;
  background: linear-gradient(135deg, transparent 50%, rgba(184,194,230,0.55) 50%, rgba(184,194,230,0.55) 60%, transparent 60%, transparent 72%, rgba(184,194,230,0.55) 72%, rgba(184,194,230,0.55) 82%, transparent 82%); border-radius: 0 0 10px 0; }
.floatpanel.sized { max-height: none !important; overflow: auto; }

.whyGroup { margin-top: 10px; } .whyGroup summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.why { font-size: 12px; line-height: 1.45; padding: 6px 8px; margin: 4px 0; border-radius: 8px; background: rgba(140,170,255,0.08); }
.why b { color: #ffc861; }
