:root { --gold: #e8c15a; --ink: #f3ead8; --bg: #120d08; --panel: #1d1610; --edge: #4a3a22; --red: #c0392b; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif; overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: none; }
button, select, input { font-family: inherit; font-size: 15px; }
button { background: linear-gradient(#5a4526, #3a2c17); color: var(--ink); border: 1px solid #8a6a36; border-radius: 6px; padding: 7px 14px; cursor: pointer; }
button:hover { filter: brightness(1.15); }
button:disabled { opacity: .45; cursor: default; filter: none; }
button.big { font-size: 18px; font-weight: 900; padding: 10px 22px; background: linear-gradient(#b8862f, #7a5414); border-color: var(--gold); color: #fff8e5; text-shadow: 0 1px 2px #000; }
button.ghost { background: transparent; border-color: #6a5430; }
select, input { background: #0d0a06; color: var(--ink); border: 1px solid #6a5430; border-radius: 6px; padding: 6px 8px; }
.screen { position: fixed; inset: 0; display: none; }
.screen.on { display: block; }
#menu, #lobby { overflow-y: auto; touch-action: pan-y; background: radial-gradient(ellipse at 50% 0%, #3b2a14 0%, #120d08 70%); }
.cedar-bg { position: fixed; inset: 0; pointer-events: none; opacity: .09; background:
  radial-gradient(circle at 50% 120%, #0f0 0 0, transparent 0),
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cpath d='M60 10 L75 35 H66 L84 58 H70 L92 85 H64 V105 H56 V85 H28 L50 58 H36 L54 35 H45 Z' fill='%2340a040'/%3E%3C/svg%3E"); }
.menu-inner { position: relative; max-width: 1100px; margin: 0 auto; padding: 18px 16px 60px; }
.title { font-family: 'Reem Kufi', 'Cairo', serif; font-size: clamp(42px, 9vw, 86px); margin: 6px 0 0; text-align: center; color: var(--gold); text-shadow: 0 0 30px #b8862f88, 0 4px 0 #5a3a10, 0 8px 18px #000; letter-spacing: 2px; }
.title.small { font-size: 46px; }
.tag { text-align: center; opacity: .85; margin: 4px 0 14px; }
h2 { color: var(--gold); border-bottom: 1px solid var(--edge); padding-bottom: 4px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.name-row { justify-content: center; }
.factions { display: grid; grid-template-columns: repeat(auto-fill, minmax(245px, 1fr)); gap: 10px; }
.fcard { background: linear-gradient(160deg, #2a2015, #15100a); border: 2px solid #3a2c17; border-radius: 10px; padding: 10px 12px; cursor: pointer; position: relative; overflow: hidden; transition: transform .12s; }
.fcard:hover { transform: translateY(-2px); }
.fcard.sel { border-color: var(--gold); box-shadow: 0 0 18px #e8c15a55; }
.fcard .stripe { position: absolute; inset: 0 auto 0 0; width: 6px; }
.fcard h4 { margin: 0 0 0 60px; font-size: 18px; }
.fcard .lead { font-size: 13px; opacity: .8; }
.fcard .sl { font-weight: 700; font-size: 13px; color: var(--gold); }
.fcard ul { margin: 6px 0 0; padding: 0 16px 0 0; font-size: 12.5px; line-height: 1.6; }
.fcard .flags { font-size: 18px; position: absolute; left: 10px; top: 8px; }
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin-top: 16px; }
.card { background: #1a140d; border: 1px solid var(--edge); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.card h3 { margin: 0; color: var(--gold); }
.card label { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hint { font-size: 13px; opacity: .7; }
.help { margin-top: 14px; background: #1a140d; border: 1px solid var(--edge); border-radius: 10px; padding: 8px 14px; }
.help summary { cursor: pointer; color: var(--gold); font-weight: 700; }
.help li { margin: 4px 0; font-size: 14px; }
.disclaimer { font-size: 12px; opacity: .55; text-align: center; margin-top: 18px; }
.code-box { text-align: center; font-size: 22px; margin: 10px 0; }
.code-box b { font-size: 34px; color: var(--gold); letter-spacing: 6px; font-family: monospace; }
.slots { width: 100%; border-collapse: collapse; margin: 10px 0; }
.slots td, .slots th { border-bottom: 1px solid #2e2414; padding: 6px; text-align: right; }
.slots .dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-left: 6px; vertical-align: middle; }
body:not(.is-host) .host-only { display: none; }

/* ---------------- game ---------------- */
#game { display: none; }
#game.on { display: flex; flex-direction: row-reverse; }
#view { position: relative; flex: 1; overflow: hidden; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: default; }
#side { width: 214px; background: linear-gradient(#21180f, #130e08); border-right: 2px solid #5a4526; display: flex; flex-direction: column; padding: 6px; gap: 5px; overflow-y: auto; touch-action: pan-y; }
.res { display: flex; flex-direction: column; gap: 3px; }
#credits { font-size: 24px; font-weight: 900; color: #7dff8a; text-shadow: 0 0 6px #0a0; direction: ltr; text-align: center; font-family: monospace; }
.power { display: flex; align-items: center; gap: 6px; font-size: 12px; }
#powerBar { flex: 1; height: 8px; background: #000; border: 1px solid #444; border-radius: 4px; overflow: hidden; }
#powerBar i { display: block; height: 100%; background: #3c3; width: 50%; }
#faction-chip { font-size: 13px; font-weight: 700; text-align: center; padding: 3px; border-radius: 5px; }
#mini { width: 100%; height: auto; border: 1px solid #5a4526; image-rendering: pixelated; cursor: pointer; touch-action: none; }
.abil { position: relative; overflow: hidden; display: flex; flex-direction: column; padding: 6px; background: linear-gradient(#6b1f1f, #3a0f0f); border-color: #c0392b; }
.abil small { font-size: 11px; opacity: .85; }
.abil i { position: absolute; inset: auto 0 0 0; height: 4px; background: #ffcc33; width: 0; }
.abil.ready { animation: pulse 1.2s infinite; }
.abil.targeting { background: #a33; }
@keyframes pulse { 50% { box-shadow: 0 0 14px #ff5544; } }
#support { font-size: 12px; text-align: center; opacity: .9; }
.tabs { display: flex; gap: 3px; }
.tabs button { flex: 1; padding: 5px 0; font-size: 13px; }
.tabs button.on { background: linear-gradient(#b8862f, #7a5414); border-color: var(--gold); }
#items { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.item { position: relative; height: 70px; padding: 3px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; line-height: 1.2; overflow: hidden; text-align: center; }
.item .ic { font-size: 24px; line-height: 1; }
.item .cost { color: #7dff8a; font-family: monospace; direction: ltr; }
.item .prog { position: absolute; inset: 0; background: #000a; transform-origin: left; pointer-events: none; }
.item .tag2 { position: absolute; top: 2px; right: 3px; font-size: 10px; background: #c0392b; border-radius: 3px; padding: 0 3px; }
.item.ready { border-color: #7dff8a; animation: pulse 1s infinite; }
.item .x { position: absolute; top: 1px; left: 2px; font-size: 12px; color: #f66; z-index: 2; }
#topbar { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; flex-wrap: wrap; z-index: 3; }
.mini { padding: 4px 9px; font-size: 13px; background: #1d1610cc; }
.mini.on { background: #b8862f; }
.touch-only { display: none; }
body.touch .touch-only { display: inline-block; }
body:not(.sp) .sp-only { display: none; }
#ticker { position: absolute; bottom: 8px; right: 8px; left: 8px; pointer-events: none; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; z-index: 2; }
#ticker div { background: #000b; padding: 3px 10px; border-radius: 5px; font-size: 14px; animation: fade 7s forwards; border-right: 3px solid var(--gold); }
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
#banner { position: absolute; top: 46px; left: 50%; transform: translateX(-50%); font-family: 'Reem Kufi', serif; font-size: 30px; color: var(--gold); text-shadow: 0 2px 8px #000; pointer-events: none; text-align: center; z-index: 2; white-space: nowrap; }
#selinfo { position: absolute; top: 44px; right: 8px; background: #000a; border-radius: 6px; padding: 4px 8px; font-size: 13px; display: none; z-index: 3; }
#selinfo button { padding: 2px 8px; font-size: 12px; margin-right: 6px; }
.modal { position: fixed; inset: 0; background: #000c; display: none; align-items: center; justify-content: center; z-index: 10; }
.modal.on { display: flex; }
.modal-in { background: #1d1610; border: 2px solid var(--gold); border-radius: 12px; padding: 20px 26px; min-width: 300px; max-width: 92vw; display: flex; flex-direction: column; gap: 10px; text-align: center; }
.modal-in h2 { font-family: 'Reem Kufi', serif; font-size: 32px; border: 0; margin: 0; }
.modal-in table { border-collapse: collapse; }
.modal-in td, .modal-in th { padding: 4px 8px; border-bottom: 1px solid #333; }
.modal-in label { display: flex; justify-content: space-between; gap: 10px; }
#toast { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); background: #000d; padding: 8px 16px; border-radius: 8px; display: none; z-index: 20; border: 1px solid var(--gold); }

@media (max-width: 760px), (max-height: 500px) {
  #side { width: 170px; padding: 4px; gap: 3px; }
  #credits { font-size: 18px; }
  .item { height: 56px; font-size: 10px; }
  .item .ic { font-size: 19px; }
  .abil { padding: 3px; }
  #banner { font-size: 20px; }
  #ticker div { font-size: 12px; }
}
@media (orientation: portrait) and (max-width: 760px) {
  #game.on { flex-direction: column-reverse; }
  #side { width: 100%; height: 38vh; border-right: 0; border-top: 2px solid #5a4526; display: grid; grid-template-columns: 120px 1fr; grid-auto-rows: min-content; }
  #side > .res, #side > #faction-chip, #side > #mini, #side > .abil, #side > #support { grid-column: 1; }
  #side > .tabs { grid-column: 2; grid-row: 1; }
  #side > #items { grid-column: 2; grid-row: 2 / span 5; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); align-content: start; }
}

#side > * { flex-shrink: 0; }

/* v2: invites, special ability, queue badges, sprite icons */
.invite-card { display: none; border-color: #25d366; margin: 6px auto 12px; max-width: 520px; text-align: center; }
body.invite .invite-card { display: flex; }
body.invite .modes { display: none; }
.invite-row { justify-content: center; }
button.wa { background: linear-gradient(#2fd36f, #128c4a); border-color: #6fffa6; }
.abil.spec { background: linear-gradient(#5d4a12, #2f2507); border-color: #e8c15a; }
.abil.spec.targeting { background: #8a6d12; }
.item .ic { width: 64px; height: 40px; object-fit: contain; font-size: 0; }
.item .cnt { position: absolute; bottom: 2px; left: 3px; font-size: 13px; font-weight: 900; color: #ffd23f; text-shadow: 0 1px 2px #000; }
.item.busy { border-color: #e8c15a; }
.item .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tabs button.alert { animation: pulse 1s infinite; }
@media (max-width: 760px), (max-height: 500px) { .item .ic { width: 48px; height: 28px; } }
.item { height: 86px; justify-content: flex-end; gap: 1px; }
@media (max-width: 760px), (max-height: 500px) { .item { height: 68px; } }
@media (orientation: portrait) and (max-width: 760px) { .mini { padding: 3px 6px; font-size: 11px; } #topbar { gap: 3px; } }
