/* ===== გალაქტიკა — visual layer ===== */
:root { --g-bg: #05060f; --g-glass: rgba(255,255,255,0.06); --g-line: rgba(255,255,255,0.12); --g-neon: #7c5cff; --g-cyan: #22d3ee; --g-gold: #fbbf24; --g-rose: #fb7185; --g-green: #4ade80; }
body { overflow: auto; background: var(--g-bg); }
#stars { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
body::before { content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none; background: radial-gradient(900px 500px at 15% -10%, rgba(124,92,255,0.28), transparent 60%), radial-gradient(700px 500px at 110% 30%, rgba(34,211,238,0.16), transparent 60%), radial-gradient(600px 600px at 50% 120%, rgba(244,114,182,0.16), transparent 60%); }
.g-app { position: relative; z-index: 1; max-width: 720px; margin: 0 auto; padding: 12px 12px calc(40px + env(safe-area-inset-bottom)); display: grid; gap: 12px; }
.g-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.g-top h1 { font-size: 22px; margin: 0; flex: 1; font-weight: 800; letter-spacing: .2px; background: linear-gradient(90deg, #fff, #c4b5fd); -webkit-background-clip: text; background-clip: text; color: transparent; }
.g-top h1 a { color: inherit; text-decoration: none; }
.g-muted { color: var(--muted); font-size: 13px; line-height: 1.45; }
.g-card { background: var(--g-glass); border: 1px solid var(--g-line); border-radius: 20px; padding: 14px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 10px 40px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.06); animation: g-in .35s ease both; }
@keyframes g-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.g-btn { border: 1px solid var(--g-line); border-radius: 999px; padding: 10px 16px; font: inherit; font-weight: 700; font-size: 14px; background: rgba(255,255,255,0.08); color: var(--fg); cursor: pointer; transition: transform .12s, box-shadow .2s, background .2s; }
.g-btn:hover { background: rgba(255,255,255,0.14); } .g-btn:active { transform: scale(.96); }
.g-btn.primary { background: linear-gradient(135deg, #7c5cff, #22d3ee); border: 0; color: #fff; box-shadow: 0 6px 24px rgba(124,92,255,0.45); }
.g-btn.warn { background: linear-gradient(135deg, #fb7185, #f97316); border: 0; color: #fff; } .g-btn.ok { background: linear-gradient(135deg, #4ade80, #22d3ee); border: 0; color: #052e16; }
.g-btn:disabled { opacity: .4; cursor: default; box-shadow: none; transform: none; }
.g-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.g-input { font: inherit; font-size: 16px; color: var(--fg); background: rgba(255,255,255,0.07); border: 1px solid var(--g-line); border-radius: 14px; padding: 11px 14px; min-width: 0; flex: 1; }
.g-input:focus { outline: 2px solid rgba(124,92,255,0.7); }
.g-hero { text-align: center; padding: 22px 14px 10px; }
.g-hero .orb { font-size: 64px; filter: drop-shadow(0 0 24px rgba(124,92,255,0.8)); animation: g-float 5s ease-in-out infinite; }
@keyframes g-float { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-8px) rotate(3deg); } }
.g-hero h2 { margin: 6px 0 2px; font-size: 26px; letter-spacing: 1px; } .g-hero p { margin: 0; color: var(--muted); }
.g-list { display: grid; gap: 8px; }
.g-gal { display: flex; align-items: center; gap: 12px; background: rgba(255,255,255,0.05); border: 1px solid var(--g-line); border-radius: 16px; padding: 12px; text-align: left; color: var(--fg); font: inherit; cursor: pointer; transition: transform .12s, border-color .2s; }
.g-gal:hover { border-color: rgba(124,92,255,0.7); transform: translateY(-1px); } .g-gal b { display: block; font-size: 15px; } .g-gal small { color: var(--muted); }
.g-gal .orb { font-size: 32px; filter: drop-shadow(0 0 10px rgba(34,211,238,0.6)); }
.g-badge { background: linear-gradient(135deg, #fb7185, #f97316); color: #fff; border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 800; box-shadow: 0 0 14px rgba(251,113,133,0.6); }
.g-status { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; } .g-status::-webkit-scrollbar { display: none; }
.g-stat { flex: 1 0 auto; min-width: 96px; background: rgba(0,0,0,0.35); border: 1px solid var(--g-line); border-radius: 14px; padding: 8px 12px; text-align: center; }
.g-stat b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; } .g-stat span { color: var(--muted); font-size: 11px; letter-spacing: .3px; text-transform: uppercase; }
.g-map { position: relative; border-radius: 24px; padding: 8px; overflow: hidden; background: radial-gradient(circle at 50% 40%, rgba(124,92,255,0.18), rgba(5,6,15,0.2) 60%), rgba(0,0,0,0.35); border: 1px solid var(--g-line); box-shadow: inset 0 0 80px rgba(0,0,0,0.6); }
.g-map svg { width: 100%; height: auto; display: block; touch-action: manipulation; }
.hex { stroke: rgba(255,255,255,0.18); stroke-width: 1.5; cursor: pointer; transition: filter .2s, stroke .2s; }
.hex:hover { filter: brightness(1.2); }
.hex.sel { stroke: #fff; stroke-width: 3; filter: url(#glow); }
.hex.adj { stroke: var(--g-gold); stroke-width: 2.5; stroke-dasharray: 5 4; animation: g-dash 1.2s linear infinite; }
@keyframes g-dash { to { stroke-dashoffset: -18; } }
.hex-lbl { pointer-events: none; font-family: var(--font); fill: #fff; font-weight: 800; }
.gem { animation: g-pulse 1.8s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes g-pulse { 0%,100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.25); opacity: 1; } }
.g-players { display: flex; gap: 6px; flex-wrap: wrap; }
.g-pl { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,0.06); border: 1px solid var(--g-line); border-radius: 999px; padding: 5px 11px 5px 7px; font-size: 13px; }
.g-pl .dot { width: 8px; height: 8px; border-radius: 50%; background: #475569; } .g-pl .dot.on { background: var(--g-green); box-shadow: 0 0 8px var(--g-green); }
.g-sw { width: 12px; height: 12px; border-radius: 4px; box-shadow: 0 0 8px currentColor; }
.g-banner { background: linear-gradient(90deg, #f43f5e, #f97316); border-radius: 16px; padding: 12px 14px; display: flex; align-items: center; gap: 10px; font-weight: 700; box-shadow: 0 8px 30px rgba(244,63,94,0.45); animation: g-shake 2.4s ease-in-out infinite; }
@keyframes g-shake { 0%,90%,100% { transform: none; } 93% { transform: translateX(-3px); } 96% { transform: translateX(3px); } }
.g-banner .g-btn { background: #fff; color: #111; border: 0; }
.g-panel h3 { margin: 0 0 6px; font-size: 16px; } .g-panel p { margin: 4px 0; }
.g-ships { display: flex; gap: 6px; flex-wrap: wrap; } .g-ship { background: rgba(0,0,0,0.35); border-radius: 10px; padding: 4px 9px; font-size: 12px; border-left: 3px solid; }
.g-count { display: inline-flex; align-items: center; gap: 8px; } .g-count button { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--g-line); background: rgba(255,255,255,0.08); color: var(--fg); font-size: 20px; } .g-count b { font-size: 20px; min-width: 20px; text-align: center; }
.g-modal { position: fixed; inset: 0; z-index: 60; background: rgba(5,6,15,0.9); display: flex; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.g-modal[hidden] { display: none; }
.g-quiz { width: 100%; max-width: 520px; display: grid; gap: 14px; animation: g-in .3s ease both; }
.g-quiz .q { font-size: clamp(20px, 3.2vh, 26px); font-weight: 800; line-height: 1.3; text-wrap: balance; }
.g-qhead { display: flex; align-items: center; gap: 12px; }
.g-ring { position: relative; width: 56px; height: 56px; flex: none; } .g-ring svg { width: 56px; height: 56px; transform: rotate(-90deg); }
.g-ring circle { fill: none; stroke-width: 5; } .g-ring .bg { stroke: rgba(255,255,255,0.12); } .g-ring .fg { stroke: var(--g-cyan); stroke-linecap: round; transition: stroke-dashoffset 1s linear, stroke .3s; }
.g-ring.warn .fg { stroke: var(--g-rose); } .g-ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 16px; font-variant-numeric: tabular-nums; }
.g-dots { display: flex; gap: 5px; } .g-dots span { width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,0.15); } .g-dots span.cur { background: var(--g-cyan); box-shadow: 0 0 8px var(--g-cyan); } .g-dots span.ok { background: var(--g-green); } .g-dots span.bad { background: var(--g-rose); }
.g-opts { display: grid; gap: 10px; }
.g-opt { display: flex; align-items: center; gap: 12px; border: 1px solid var(--g-line); background: rgba(255,255,255,0.06); color: var(--fg); border-radius: 16px; padding: 13px 14px; font: inherit; font-size: 16px; text-align: left; cursor: pointer; transition: transform .1s, border-color .15s, background .15s; }
.g-opt:hover { border-color: rgba(124,92,255,0.8); background: rgba(124,92,255,0.12); } .g-opt:active { transform: scale(.98); }
.g-opt .k { flex: none; width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; background: rgba(255,255,255,0.1); font-weight: 800; font-size: 14px; }
.g-opt.picked { border-color: var(--g-cyan); background: rgba(34,211,238,0.15); box-shadow: 0 0 18px rgba(34,211,238,0.35); }
.g-opt:disabled { cursor: default; }
.g-result { text-align: center; display: grid; gap: 12px; justify-items: center; }
.g-result .big { font-size: 80px; line-height: 1; filter: drop-shadow(0 0 30px rgba(124,92,255,0.8)); animation: g-pop .5s cubic-bezier(.2,.9,.3,1.4) both; }
@keyframes g-pop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.g-result h2 { margin: 0; font-size: 24px; text-wrap: balance; }
.g-detail { display: flex; gap: 5px; justify-content: center; flex-wrap: wrap; } .g-detail span { width: 30px; height: 30px; border-radius: 9px; display: inline-grid; place-items: center; font-size: 14px; font-weight: 800; }
.g-detail .ok { background: rgba(74,222,128,0.3); color: #bbf7d0; } .g-detail .bad { background: rgba(251,113,133,0.3); color: #fecdd3; }
.g-vs { width: 100%; display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; background: rgba(0,0,0,0.35); border: 1px solid var(--g-line); border-radius: 18px; padding: 12px; font-size: 13px; }
.g-vs b { font-size: 26px; display: block; } .g-vs .vs { font-size: 20px; font-weight: 800; background: linear-gradient(90deg, #fb7185, #fbbf24); -webkit-background-clip: text; background-clip: text; color: transparent; }
.g-vs > div:first-child { border-left: 4px solid var(--g-cyan); padding-left: 8px; } .g-vs > div:last-child { border-right: 4px solid var(--g-rose); padding-right: 8px; }
.g-log { display: grid; gap: 6px; } .g-log div { background: rgba(0,0,0,0.3); border: 1px solid var(--g-line); border-radius: 12px; padding: 8px 10px; font-size: 13px; cursor: pointer; }
.g-help { font-size: 13px; color: var(--muted); line-height: 1.5; } .g-help b { color: var(--fg); }
.g-shop { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.g-shop .g-btn { padding: 12px 10px; border-radius: 16px; }
@media (prefers-reduced-motion: reduce) { .g-card, .g-hero .orb, .hex.adj, .gem, .g-banner, .g-result .big { animation: none; } }

/* ----- 3D map ----- */
.g-map3d { padding: 0; aspect-ratio: 1 / 0.94; min-height: 300px; background: radial-gradient(circle at 50% 55%, rgba(124,92,255,0.22), rgba(5,6,15,0.1) 62%), rgba(0,0,0,0.3); }
.m3-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.m3-canvas:active { cursor: grabbing; }
.m3-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.m3-lbl { position: absolute; transform: translate(-50%, -50%); font-size: 12px; font-weight: 800; color: rgba(255,255,255,0.75); text-shadow: 0 1px 3px #000; white-space: nowrap; }
.m3-ships { position: absolute; transform: translate(-50%, -50%); font-size: 12px; font-weight: 800; padding: 1px 7px; border-radius: 999px; border: 2px solid; background: rgba(8,8,20,0.85); color: #fff; white-space: nowrap; box-shadow: 0 2px 10px rgba(0,0,0,0.5); }
.m3-ships.mine { background: #fff; color: #111; }
@media (min-width: 640px) { .g-map3d { aspect-ratio: 1 / 0.72; } }

/* ----- status bar ----- */
.g-turn { display: flex; align-items: center; gap: 12px; border-radius: 18px; padding: 12px 14px; border: 1px solid var(--g-line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); animation: g-in .3s ease both; }
.g-turn .ico { flex: none; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-size: 24px; background: rgba(0,0,0,0.3); }
.g-turn .txt { flex: 1; min-width: 0; display: grid; gap: 2px; } .g-turn .txt b { font-size: 16px; } .g-turn .txt span { font-size: 13px; color: rgba(255,255,255,0.82); line-height: 1.4; }
.g-turn .g-cd { font-variant-numeric: tabular-nums; font-size: inherit; }
.g-turn.go { background: linear-gradient(135deg, rgba(74,222,128,0.28), rgba(34,211,238,0.16)); border-color: rgba(74,222,128,0.6); box-shadow: 0 0 24px rgba(74,222,128,0.2); }
.g-turn.wait { background: linear-gradient(135deg, rgba(251,191,36,0.24), rgba(249,115,22,0.12)); border-color: rgba(251,191,36,0.55); }
.g-turn.danger { background: linear-gradient(135deg, #f43f5e, #f97316); border: 0; box-shadow: 0 8px 30px rgba(244,63,94,0.45); animation: g-shake 2.4s ease-in-out infinite; }
.g-turn.danger .g-btn { background: #fff; color: #111; border: 0; flex: none; }
.g-pl.me { border-color: rgba(255,255,255,0.6); background: rgba(255,255,255,0.12); }
.g-tag { font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 999px; background: rgba(251,191,36,0.25); } .g-tag.think { background: rgba(34,211,238,0.28); } .g-tag.off { background: none; padding: 0; }
.hex.hint { stroke: #fff; stroke-width: 2.5; animation: g-hint 1.2s ease-in-out infinite; }
@keyframes g-hint { 0%,100% { stroke-opacity: .35; } 50% { stroke-opacity: 1; } }

/* ----- answer feedback + review ----- */
.g-modal { overflow-y: auto; align-items: flex-start; } .g-quiz { margin: auto; }
.g-opt.ok { border-color: var(--g-green); background: rgba(74,222,128,0.22); box-shadow: 0 0 18px rgba(74,222,128,0.35); }
.g-opt.ok .k { background: var(--g-green); color: #052e16; }
.g-opt.bad { border-color: var(--g-rose); background: rgba(251,113,133,0.2); } .g-opt.bad .k { background: var(--g-rose); color: #4c0519; }
.g-fb { margin: 0; min-height: 1.4em; font-size: 14px; color: var(--muted); } .g-fb.ok { color: #86efac; font-weight: 800; } .g-fb.bad { color: #fda4af; font-weight: 800; }
.g-review { width: 100%; display: grid; gap: 8px; text-align: left; } .g-review:empty { display: none; } .g-review h3 { margin: 6px 0 0; font-size: 15px; }
.g-rev { background: rgba(0,0,0,0.3); border: 1px solid var(--g-line); border-left: 4px solid var(--g-green); border-radius: 12px; padding: 9px 12px; display: grid; gap: 3px; font-size: 14px; }
.g-rev.bad { border-left-color: var(--g-rose); } .g-rev .rq { color: var(--muted); font-size: 13px; } .g-rev .ra { font-weight: 800; } .g-rev .rw { color: #fda4af; font-size: 13px; } .g-rev .rm { color: var(--muted); font-size: 12px; }
.g-dots span.done { background: rgba(255,255,255,0.6); }

/* ----- match goal, siege progress, ranking ----- */
.g-stat.goal { border-color: rgba(251,191,36,0.6); background: rgba(251,191,36,0.12); }
.g-siege { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 800; }
.g-siege .bar { display: flex; gap: 4px; } .g-siege .bar i { width: 26px; height: 10px; border-radius: 999px; background: rgba(255,255,255,0.15); } .g-siege .bar i.on { background: var(--g-gold); box-shadow: 0 0 10px rgba(251,191,36,0.7); }
.g-ranks { width: 100%; display: grid; gap: 6px; }
.g-rank { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,0.3); border: 1px solid var(--g-line); border-radius: 12px; padding: 9px 12px; font-size: 15px; } .g-rank.me { border-color: rgba(255,255,255,0.6); } .g-rank b { width: 28px; }
/* fact card after a wrong answer, solo start, review facts */
.g-fact { display: grid; gap: 10px; justify-items: center; text-align: center; animation: g-in .3s ease both; }
.g-fact .fe { font-size: 54px; line-height: 1; filter: drop-shadow(0 6px 18px rgba(251,191,36,0.45)); }
.g-fact h3 { margin: 0; font-size: 19px; line-height: 1.3; }
.g-fact p { margin: 0; font-size: 16px; line-height: 1.55; color: rgba(255,255,255,0.9); text-align: left; background: rgba(0,0,0,0.3); border: 1px solid var(--g-line); border-left: 4px solid #fbbf24; border-radius: 14px; padding: 12px 14px; }
.g-fact .g-btn { width: 100%; }
.g-turn-btns { display: grid; gap: 6px; flex: none; } .g-turn-btns .g-btn { white-space: nowrap; }
.g-rev .rf { color: rgba(255,255,255,0.78); font-size: 13px; line-height: 1.45; border-top: 1px dashed var(--g-line); padding-top: 5px; margin-top: 2px; }
/* whose turn it is */
.g-pl.turn { border-color: #4ade80; box-shadow: 0 0 14px rgba(74,222,128,0.35); }
.g-now { color: #4ade80; font-size: 11px; animation: g-blink 1.2s ease-in-out infinite; }
@keyframes g-blink { 50% { opacity: .35; } }
.g-turn { flex-wrap: wrap; }
.g-turn .txt { flex: 1 1 60%; }
#g-end { flex: 1 0 100%; font-size: 13px; padding: 9px 12px; background: rgba(0,0,0,0.28); }
.g-turn .g-turn-btns { flex: 1 0 100%; grid-template-columns: 1fr 1fr; }
/* match settings: in the create form (inside <details>) and in the owner's settings dialog */
.g-rules summary { cursor: pointer; color: var(--g-muted, rgba(255,255,255,0.7)); font-size: 14px; padding: 4px 2px; }
.g-settings { display: grid; gap: 10px; margin-top: 8px; }
.g-settings label { display: grid; gap: 4px; font-size: 13px; text-align: left; }
.g-settings label span { opacity: 0.85; }
