:root {
  --sea: #0a1a26;
  --panel: #0f2230;
  --panel-hi: #163246;
  --panel-lo: #0a1823;
  --gold: #c9a45c;
  --gold-hi: #f3d488;
  --gold-lo: #6d5527;
  --text: #f1e7cf;
  --muted: #a8a088;
  --good: #7fd48a;
  --bad: #ff7a6b;
  --frame: inset 0 0 0 1px #000, inset 0 0 0 2px var(--gold-lo), 0 0 0 1px var(--gold), 0 0 0 2px #000, 0 8px 24px rgba(0,0,0,.7);
  --title: 'Cinzel', 'Trajan Pro', Georgia, serif;
  --body: 'PT Sans', 'Segoe UI', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--sea); color: var(--text); font: 14px/1.4 var(--body); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--title); font-weight: 700; margin: 0 0 8px; color: var(--gold-hi); letter-spacing: .04em; }
h2 { font-size: 20px; text-align: center; text-shadow: 0 2px 4px #000; }
h3 { font-size: 13px; margin-top: 16px; padding-bottom: 3px; border-bottom: 1px solid var(--gold-lo); text-transform: uppercase; }
.muted { color: var(--muted); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; margin-right: 4px; box-shadow: 0 0 0 1px #000; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
td, th { padding: 4px; border-bottom: 1px solid rgba(201,164,92,.18); text-align: left; }
th { color: var(--gold); font-weight: 600; font-family: var(--title); font-size: 11px; }

/* buttons & inputs */
button {
  background: linear-gradient(#1d3d52, #0d2231); border: 1px solid var(--gold-lo); border-radius: 4px; padding: 5px 10px; cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08); transition: border-color .12s, box-shadow .12s;
}
button:hover:not(:disabled) { border-color: var(--gold-hi); box-shadow: 0 0 8px rgba(243,212,136,.35), inset 0 1px 0 rgba(255,255,255,.12); }
button:disabled { opacity: .4; cursor: not-allowed; }
button.primary { background: linear-gradient(#e7c879, #a07a32); color: #1b1305; border-color: var(--gold-hi); font-family: var(--title); font-weight: 700; }
button.danger { border-color: #8a3b30; color: var(--bad); }
button.small { padding: 2px 8px; font-size: 12px; }
input, select, textarea { background: #071219; border: 1px solid var(--gold-lo); border-radius: 3px; padding: 5px 8px; }
input:focus, select:focus { outline: none; border-color: var(--gold-hi); }
input[type=number] { width: 70px; }
.frame { background: linear-gradient(var(--panel-hi), var(--panel) 30%, var(--panel-lo)); box-shadow: var(--frame); border-radius: 4px; position: relative; }
.frame::before, .frame::after { content: ''; position: absolute; width: 9px; height: 9px; background: var(--gold); transform: rotate(45deg); top: -5px; box-shadow: 0 0 0 1px #000; }
.frame::before { left: 14px; }
.frame::after { right: 14px; }

/* menus: join & lobby */
.menu-bg {
  min-height: 100%; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(22,50,70,.6), transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='52' height='90' viewBox='0 0 52 90'%3E%3Cpath d='M26 0 52 15v30L26 60 0 45V15zM26 60v30M0 45l-0 0M52 45v0' fill='none' stroke='%23c9a45c' stroke-opacity='.08'/%3E%3C/svg%3E"), var(--sea);
}
.card { padding: 26px 24px 22px; width: 100%; max-width: 430px; }
.card input { width: 100%; margin-bottom: 10px; }
.logo { font-family: var(--title); font-size: 40px; font-weight: 900; text-align: center; color: var(--gold-hi); letter-spacing: .08em; text-shadow: 0 3px 0 #3d2c0c, 0 0 18px rgba(243,212,136,.3); }
.tagline { text-align: center; font-style: italic; color: var(--muted); margin: 0 0 16px; }
.divider { height: 1px; margin: 14px 0; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
.code { font-family: var(--title); font-size: 46px; font-weight: 900; letter-spacing: .25em; color: var(--gold-hi); text-align: center; margin: 4px 0 10px; text-shadow: 0 2px 0 #000; }
.plist { list-style: none; padding: 0; margin: 10px 0; }
.plist li { padding: 7px 4px; border-bottom: 1px solid rgba(201,164,92,.2); display: flex; align-items: center; gap: 8px; }

/* in-game layout: full-bleed map, floating framed panels */
#game { position: fixed; inset: 0; overflow: hidden; }
#mapwrap {
  position: absolute; inset: 0; touch-action: none;
  background: radial-gradient(ellipse at center, #10324a, #071520 75%);
}
#mapwrap::after { content: ''; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 140px 30px rgba(0,0,0,.75); }
#map { width: 100%; height: 100%; display: block; cursor: grab; user-select: none; }
#map:active { cursor: grabbing; }
#map .hex { stroke: rgba(0,0,0,.35); stroke-width: .8; }
#map .hex:hover { filter: brightness(1.22); }
#map text { pointer-events: none; text-anchor: middle; dominant-baseline: central; }
#map .lbl { font: 600 8px var(--body); fill: #fff; paint-order: stroke; stroke: #000; stroke-width: 2.2px; }
#map .linehit { stroke: transparent; stroke-width: 12; cursor: pointer; }
#map .sel { fill: none; stroke: var(--gold-hi); stroke-width: 2.5; pointer-events: none; filter: drop-shadow(0 0 4px var(--gold-hi)); }
#map .plan { fill: none; stroke: var(--gold-hi); stroke-width: 2; stroke-dasharray: 5 4; pointer-events: none; }
#map .banner-name { font: 700 8.5px var(--title); fill: #fff; letter-spacing: .03em; }

/* top bar */
#hdr {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 0 12px; height: 38px;
  background: linear-gradient(#18374c, #0a1923); border-bottom: 2px solid var(--gold); box-shadow: 0 3px 12px rgba(0,0,0,.7);
}
.yield { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.yield b { font-size: 15px; }
.yield small { font-size: 12px; }
.hdr-mid { flex: 1; text-align: center; font-family: var(--title); color: var(--gold-hi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.advisors { display: flex; gap: 4px; }
.advisors button { font-family: var(--title); font-size: 12px; padding: 3px 9px; position: relative; }
.advisors button.on { border-color: var(--gold-hi); background: linear-gradient(#2c5470, #12303f); }
.badge { position: absolute; top: -6px; right: -6px; background: #b8322a; color: #fff; border-radius: 9px; min-width: 17px; height: 17px; font: 700 11px/17px var(--body); text-align: center; box-shadow: 0 0 0 1px #000; padding: 0 4px; }

/* players ribbon */
#ribbon { position: absolute; top: 46px; right: 12px; z-index: 4; display: flex; gap: 8px; }
.leader { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; position: relative; font: 700 17px var(--title); color: #fff; text-shadow: 0 1px 2px #000; box-shadow: 0 0 0 2px #000, 0 0 0 4px var(--gold), 0 3px 8px rgba(0,0,0,.7); cursor: default; }
.leader.off { filter: grayscale(.9) brightness(.6); }
.leader .st { position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%); font-size: 11px; background: #0a1823; border: 1px solid var(--gold-lo); border-radius: 6px; padding: 0 4px; white-space: nowrap; font-family: var(--body); }
.leader .crown { position: absolute; top: -10px; font-size: 13px; }

/* notifications */
#notifs { position: absolute; right: 16px; bottom: 236px; z-index: 4; display: flex; flex-direction: column-reverse; gap: 8px; align-items: flex-end; }
.notif { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; position: relative; padding: 0;
  background: radial-gradient(circle at 35% 30%, #2f5c78, #0b1d29); border: 2px solid var(--gold); box-shadow: 0 0 0 1px #000, 0 4px 10px rgba(0,0,0,.7); }
.notif.alert { border-color: #e2584b; animation: pulse 1.6s infinite; }
.notif .badge { top: -4px; right: -4px; }
.notif .ntip { display: none; position: absolute; right: 56px; top: 50%; transform: translateY(-50%); white-space: nowrap; font-size: 13px; padding: 5px 10px; }
.notif:hover .ntip { display: block; }
@keyframes pulse { 50% { box-shadow: 0 0 0 1px #000, 0 0 16px 3px rgba(226,88,75,.7); } }

/* left advisor panel */
#panel { position: absolute; top: 50px; left: 12px; bottom: 12px; width: 390px; z-index: 6; display: flex; flex-direction: column; transition: transform .2s; }
#panel.closed { transform: translateX(-440px); }
#panelhead { display: flex; align-items: center; padding: 10px 14px 8px; border-bottom: 1px solid var(--gold-lo); }
#panelhead h2 { margin: 0; flex: 1; text-align: left; }
#tabbody { padding: 10px 14px 14px; overflow: auto; flex: 1; }
.btnx { background: none; border: 0; font-size: 18px; color: var(--gold); padding: 0 4px; box-shadow: none; }
.btnx:hover:not(:disabled) { color: var(--gold-hi); box-shadow: none; }

/* bottom-left selection panel */
#insp { position: absolute; left: 12px; bottom: 12px; width: 410px; max-height: 52vh; z-index: 5; display: flex; flex-direction: column; }
#insp.hidden { display: none; }
#game.panel-open #insp { left: 414px; }
.unit-head { display: flex; gap: 12px; align-items: center; padding: 12px 14px 8px; border-bottom: 1px solid var(--gold-lo); }
.medal { width: 58px; height: 58px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 30px; background: radial-gradient(circle at 35% 30%, #355f7b, #0b1b26); box-shadow: 0 0 0 2px #000, 0 0 0 4px var(--gold), 0 0 0 5px #000; }
.unit-title { font: 700 16px var(--title); color: var(--gold-hi); }
.unit-body { padding: 8px 14px 12px; overflow: auto; }
.unit-body .info div { margin-bottom: 2px; }
.stat-bars { display: grid; grid-template-columns: auto 1fr auto; gap: 3px 8px; align-items: center; font-size: 12px; margin: 4px 0 6px; }
.meter { height: 7px; background: #061017; border: 1px solid #000; border-radius: 4px; overflow: hidden; }
.meter > div { height: 100%; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-top: 8px; }
.actions button { text-align: left; font-size: 13px; display: flex; gap: 7px; align-items: center; padding: 5px 8px; }
.actions button .ai { font-size: 18px; width: 22px; text-align: center; flex: none; }
.actions button small { display: block; color: var(--muted); font-size: 11px; }
.actions .wide { grid-column: 1 / -1; }

/* bottom-right: end turn + minimap */
#turnbox { position: absolute; right: 12px; bottom: 12px; z-index: 5; width: 250px; }
.nextturn {
  display: block; width: 100%; padding: 9px 8px 7px; font: 900 17px var(--title); letter-spacing: .08em; color: #1b1305; border: 0; border-radius: 4px 4px 0 0;
  background: linear-gradient(#f5dc95, #c69b45 55%, #8f6a26); box-shadow: inset 0 1px 0 #fff6d5, 0 0 0 1px #000, 0 0 0 2px var(--gold-hi), 0 4px 14px rgba(0,0,0,.7);
}
.nextturn small { display: block; font: 600 11px var(--body); letter-spacing: 0; color: #3a2a0c; }
.nextturn.waiting { background: linear-gradient(#5b7d93, #2e4f63 60%, #1c3646); color: var(--text); }
.nextturn.waiting small { color: #d7e3ea; }
.nextturn:hover:not(:disabled) { filter: brightness(1.08); box-shadow: inset 0 1px 0 #fff6d5, 0 0 0 1px #000, 0 0 0 2px var(--gold-hi), 0 0 18px rgba(243,212,136,.5); }
.mm { border-radius: 0 0 4px 4px; padding: 6px; }
.mm svg { width: 100%; height: 150px; display: block; background: #071520; cursor: pointer; border: 1px solid #000; }
.lenses { display: flex; gap: 4px; margin-bottom: 5px; }
.lenses button { flex: 1; padding: 2px 0; font-size: 14px; }
.lenses button.on { border-color: var(--gold-hi); background: linear-gradient(#2c5470, #12303f); }
.forceend { display: block; width: 100%; margin-top: 5px; font-size: 12px; }

/* map overlays */
.mapbanner { position: absolute; left: 50%; top: 50px; transform: translateX(-50%); z-index: 6; padding: 8px 14px; display: flex; gap: 8px; align-items: center; font-family: var(--title); color: var(--gold-hi); white-space: nowrap; }
.maphint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 3; font-size: 12px; color: var(--muted); text-shadow: 0 1px 2px #000; pointer-events: none; white-space: nowrap; }
#tip { position: absolute; z-index: 7; pointer-events: none; padding: 7px 10px; font-size: 12px; min-width: 170px; display: none; }
#tip b { font-family: var(--title); color: var(--gold-hi); }

/* panel content */
.action { display: flex; justify-content: space-between; align-items: center; background: rgba(0,0,0,.25); border: 1px solid rgba(201,164,92,.25); border-radius: 3px; padding: 5px 8px; margin-bottom: 4px; }
.objective { background: linear-gradient(135deg, #3d2f0e, #172b38); border: 1px solid var(--gold); border-radius: 4px; padding: 9px 11px; margin-top: 10px; }
.objective b { font-family: var(--title); color: var(--gold-hi); }
.cardx { background: linear-gradient(#1b3a4e, #10222f); border: 1px solid var(--gold-lo); border-left: 4px solid var(--muted); border-radius: 3px; padding: 6px 9px; margin-bottom: 6px; }
.cardx.sabotage { border-left-color: #d0493d; }
.cardx.lobbying { border-left-color: #9b7cff; }
.cardx.response { border-left-color: #59c06c; }
.cardx b { display: block; font-family: var(--title); font-size: 13px; color: var(--gold-hi); }
.cardx p { margin: 2px 0 5px; font-size: 12px; color: var(--muted); }
.chat { max-height: 220px; overflow: auto; background: rgba(0,0,0,.35); border: 1px solid rgba(201,164,92,.25); border-radius: 3px; padding: 6px; font-size: 13px; margin-bottom: 6px; }
.chat .whisper { font-style: italic; color: #cdb8ff; }
.offer { background: rgba(0,0,0,.25); border: 1px solid rgba(201,164,92,.25); border-radius: 3px; padding: 6px 8px; margin-bottom: 5px; font-size: 13px; }
.log { font-size: 12px; }
.log div { padding: 2px 0; border-bottom: 1px dashed rgba(201,164,92,.15); }
.log .turnhdr { color: var(--gold-hi); font-family: var(--title); border: 0; padding-top: 8px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 10; padding: 16px; }
.modal .card { max-width: 580px; max-height: 90vh; overflow: auto; }
#toast { position: fixed; top: 52px; left: 50%; transform: translateX(-50%); background: linear-gradient(#7e2a22, #4d1712); border: 1px solid var(--gold); color: #fff; padding: 8px 16px; border-radius: 4px; display: none; z-index: 20; max-width: 90vw; box-shadow: 0 4px 12px rgba(0,0,0,.6); }

@media (max-width: 900px) {
  #hdr { height: auto; flex-wrap: wrap; gap: 6px 12px; padding: 5px 8px; }
  .hdr-mid { order: 9; flex-basis: 100%; }
  #ribbon { top: auto; bottom: 8px; left: 8px; right: auto; }
  .leader { width: 32px; height: 32px; font-size: 14px; }
  #panel { top: 0; left: 0; bottom: 0; width: 100%; max-width: 420px; z-index: 8; }
  #panel.closed { transform: translateX(-110%); }
  #insp, #game.panel-open #insp { left: 0; right: 0; bottom: 0; width: auto; max-height: 50vh; z-index: 7; }
  #turnbox { width: 170px; top: 96px; bottom: auto; right: 8px; }
  .mm { display: none; }
  .nextturn { border-radius: 4px; font-size: 14px; }
  #notifs { bottom: auto; top: 160px; right: 10px; }
  .notif { width: 38px; height: 38px; font-size: 18px; }
  .maphint { display: none; }
}
