* { box-sizing: border-box; }
:root { --cell: 44px; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #1d2430; color: #e8e8e8; display: flex; flex-direction: column;
}
button {
  background: #3a4556; color: #fff; border: 1px solid #56637a; border-radius: 4px;
  padding: 6px 12px; cursor: pointer; font-size: 14px;
}
button:hover:not(:disabled) { background: #4a5870; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: #2e7d32; border-color: #43a047; }
button.primary:hover:not(:disabled) { background: #388e3c; }

#topbar {
  display: flex; align-items: center; gap: 12px; padding: 8px 14px; flex-shrink: 0; white-space: nowrap;
  background: #121821; border-bottom: 1px solid #2c3646;
}
.brand { font-weight: 700; font-size: 16px; min-width: 0; flex: 0 1 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#status { flex: 0 1 auto; min-width: 0; display: flex; gap: 14px; align-items: center; flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; font-size: 14px; scrollbar-width: none; }
#status > span { flex-shrink: 0; }
#actions-menu { position: relative; }
#actions-menu summary { cursor: pointer; padding: 6px 12px; border: 1px solid #56637a; border-radius: 4px; background: #3a4556; font-size: 14px; }
#actions-menu summary:hover { background: #4a5870; }
.actions-dropdown { position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; display: flex; flex-direction: column; gap: 6px; padding: 10px; width: 240px; max-height: 70dvh; overflow-y: auto; background: #1f2835; border: 1px solid #56637a; border-radius: 6px; box-shadow: 0 8px 24px #0008; }
.actions-dropdown > button { text-align: left; }
.actions-dropdown .speed { justify-content: space-between; }
.actions-dropdown .zoom { justify-content: center; }
#status .status-leader { width: 26px; height: 26px; flex: none; object-fit: cover; border: 1px solid #b7a36d; border-radius: 50%; background: #20252d; }
#status .civ-chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
#status .civ-chip.talk { cursor: pointer; }
#status .civ-chip.talk:hover { text-decoration: underline; }
.peace-tag { font-size: 12px; color: #a5d6a7; font-weight: 600; }
.swatch { width: 12px; height: 12px; border-radius: 2px; display: inline-block; border: 1px solid #000; }
.progress { width: 120px; height: 8px; background: #333; border-radius: 4px; overflow: hidden; display: inline-block; vertical-align: middle; }
.progress > div { height: 100%; background: #4fc3f7; }
.actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#map-wrap { flex: 1; overflow: hidden; padding: 10px; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
#map-wrap.dragging, #map-wrap.dragging .cell { cursor: grabbing; }
#map img { -webkit-user-drag: none; }
#map { display: grid; gap: 0; width: max-content; border: 2px solid #000; position: relative; background-size: var(--cell) var(--cell); }

.cell {
  width: var(--cell); height: var(--cell); position: relative; background-size: cover;
  image-rendering: pixelated; cursor: grab; touch-action: none;
}
@media (hover: hover) {
  .cell:hover { outline: 2px solid rgba(255,255,255,.6); outline-offset: -2px; z-index: 2; }
}
/* Pseudo-element, not inset shadow: it isn't clipped by rounded shore corners, so the water there is dimmed too. */
.cell.fog::before { content: ""; position: absolute; inset: 0; background: rgba(0, 0, 0, .3); pointer-events: none; z-index: 1; }
.terrain-art { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; image-rendering: pixelated; }
.coast-art { inset: auto; width: 50%; height: 50%; }
.coast-art.corner-0 { left: 0; top: 0; }
.coast-art.corner-1 { right: 0; top: 0; }
.coast-art.corner-2 { right: 0; bottom: 0; }
.coast-art.corner-3 { left: 0; bottom: 0; }
.mine { position: absolute; left: 20%; bottom: 3%; width: 60%; height: 60%; pointer-events: none; z-index: 1; }
.cell.reach::after, .cell.attack::after, .cell.selected::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
}
.cell.reach::after { background: rgba(255,255,255,.28); box-shadow: inset 0 0 0 1px rgba(255,255,255,.7); }
.cell.attack::after { background: rgba(229,57,53,.45); box-shadow: inset 0 0 0 2px #e53935; }
.cell.selected::after { box-shadow: inset 0 0 0 3px #ffeb3b; }

.city {
  position: absolute; inset: 1px; border: 3px solid; border-radius: 4px;
  background-size: 82% 82%; background-position: center; background-repeat: no-repeat;
  pointer-events: none;
}
.city-name {
  position: absolute; left: 50%; top: -14px; transform: translateX(-50%);
  font-size: 10px; font-weight: 700; white-space: nowrap; padding: 0 4px; border-radius: 3px;
  color: #fff; pointer-events: none; z-index: 3; text-shadow: 0 1px 1px #000;
}
.city-name .city-pop { background: rgba(0,0,0,.45); border-radius: 3px; padding: 0 3px; margin-left: -3px; }
.wonder { position: absolute; inset: 12%; display: grid; place-items: center; color: #ffe082; font-size: calc(var(--cell) * .65); background: #42331dde; border: 2px solid #d5ad58; border-radius: 50%; text-shadow: 0 0 8px #ffd54f; pointer-events: none; }
.wonder-result { text-align: center; padding: 12px; border: 1px solid #a88b4c; border-radius: 6px; background: linear-gradient(135deg, #393123, #1f2835); }
.wonder-result h2 { color: #ffe082; }
.wonder-result p { line-height: 1.6; }
.wonder-emblem { color: #ffe082; font-size: 56px; text-shadow: 0 0 20px #b58935; }
.wonder-art { margin-bottom: 8px; }
.wonder-illustration { display: block; width: min(320px, 100%); margin: 0 auto; border-radius: 6px; border: 1px solid #a88b4c66; opacity: .8; filter: brightness(.85) saturate(.9); }
.city-prod { position: absolute; right: 0; top: 0; font-size: 11px; pointer-events: none; }
.unit-badge {
  position: absolute; left: 2px; bottom: 2px; width: calc(var(--cell) * .7); height: calc(var(--cell) * .7); padding: 0;
  border-radius: 50%; border: max(1px, calc(var(--cell) * .025)) solid #000; display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--cell) * .6); line-height: 1; pointer-events: none; z-index: 2; box-shadow: 0 1px 2px rgba(0,0,0,.6);
}
.unit-badge .cnt { position: absolute; right: -3px; bottom: -2px; padding: 1px 2px; border-radius: 3px; background: #111c; font-size: max(6px, calc(var(--cell) * .22)); font-weight: 700; color: #fff; text-shadow: 0 0 2px #000; }
.unit-badge.rebel { border-color: #ff5252; border-radius: 3px; }
.unit-badge.rebel::before { content: ''; position: absolute; inset: -6px; background: #ff5252; clip-path: polygon(evenodd, 0% 15%, 15% 15%, 15% 0%, 35% 10%, 50% 0%, 65% 10%, 85% 0%, 85% 15%, 100% 15%, 90% 35%, 100% 50%, 90% 65%, 100% 85%, 85% 85%, 85% 100%, 65% 90%, 50% 100%, 35% 90%, 15% 100%, 15% 85%, 0% 85%, 10% 65%, 0% 50%, 10% 35%, 0% 15%, 20% 20%, 20% 80%, 80% 80%, 80% 20%, 20% 20%, 0% 15%); }
.unit-badge.rebel::after { content: '!'; position: absolute; top: -13px; right: -8px; display: grid; place-items: center; width: 14px; height: 16px; border: 1px solid #ff5252; border-radius: 3px; background: #641f22; color: #fff; font-size: 13px; font-weight: 800; line-height: 1; }
.unit-badge.fort { border-style: dashed; }
.unit-badge.done { filter: grayscale(.6) brightness(.8); }
.unit-badge .extract { position: absolute; top: -7px; right: -6px; font-size: 10px; }

#side {
  width: 100%; max-height: 36dvh; flex: none; background: #161d28; border-top: 2px solid #2c3646;
  display: flex; flex-direction: column; min-height: 0;
}
#panel { padding: 10px 12px; min-height: 0; overflow: auto; max-height: calc(36dvh - 2px); flex: 0 1 auto; }
body.show-log #side { height: 36dvh; }
body.show-log #log-wrap { display: flex; }
body.show-log #panel { display: none; }
#panel h2 { margin: 0 0 6px; font-size: 17px; }
#panel .row { margin: 4px 0; font-size: 14px; }
#panel .btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
#panel .btns.unit-actions button { flex: 0 0 auto; padding: 6px 4px; white-space: nowrap; }
#panel .unit-list { list-style: none; padding: 0; margin: 8px 0; }
#panel .unit-list li { padding: 4px 6px; border-radius: 4px; cursor: pointer; font-size: 14px; }
#panel .unit-list li:hover, #panel .unit-list li.cur { background: #2a3546; }
.muted { color: #8b95a5; }
.hint { color: #8b95a5; font-size: 13px; margin-top: 10px; line-height: 1.4; }

#log-wrap { flex: 1; display: none; flex-direction: column; min-height: 0; padding: 0 12px 12px; }
#log-wrap h3 { margin: 10px 0 6px; font-size: 14px; color: #aab; }
#log { flex: 1; overflow: auto; font-size: 12.5px; line-height: 1.35; }
#log div { padding: 3px 0; border-bottom: 1px solid #222b38; }
#log .t { color: #6b7585; margin-right: 4px; }
#log .good { color: #81c784; }
#log .bad { color: #ef9a9a; }
#log .tech { color: #4fc3f7; }
#log .muted { color: #7c8696; }

#modal {
  position: fixed; inset: 0; background: rgba(240, 246, 250, .16); display: flex;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; z-index: 50;
}
#modal.hidden { display: none; }
#modal-box {
  background: #1f2835; border: 1px solid #3a4556; border-radius: 8px; padding: 18px 20px;
  width: min(820px, 94vw); max-height: 90vh; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,.6);
}
.modal-x {
  position: sticky; top: 6px; z-index: 2; display: block; width: 30px; height: 30px;
  margin: -4px -2px -30px auto; padding: 0; border-radius: 50%;
  border: 1px solid #3b4c62; background: #263242; color: #cfd8dc;
  font-size: 14px; line-height: 1; cursor: pointer;
  transition: transform .25s ease, border-color .15s ease;
}
.modal-x:hover { transform: rotate(90deg); border-color: #7d92ad; color: #fff; }
.modal-x-inline { position: static; margin: 0; }
.leader-chip { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; border: 1px solid #3b4c62; vertical-align: middle; margin-right: 6px; }
#modal-box h2 { margin: 0 0 4px; }
#modal-box h3 { margin: 16px 0 6px; font-size: 15px; color: #cfd8dc; }
.city-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
#modal-box:is(.city-dialog, .tech-dialog, .lobby-dialog, .leader-picker-dialog) {
  width: min(880px, 96vw); max-height: 94dvh; padding: 16px 22px; border: 1px solid #9e8c63; border-radius: 2px;
  background: radial-gradient(ellipse at 50% 0, #282c34 0, transparent 65%), #13171e;
  color: #d5d3cd; box-shadow: 0 20px 80px #000c, inset 0 0 0 4px #15191f, inset 0 0 0 5px #655d4538;
  scrollbar-color: #8b8066 #1b1e25; scrollbar-width: thin;
}
#modal-box:is(.city-dialog, .tech-dialog, .lobby-dialog, .leader-picker-dialog) h3 { margin: 10px 0 6px; font: 13px Georgia, 'Times New Roman', serif; letter-spacing: .08em; color: #c8b88a; }
.city-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 16px; padding: 2px 24px 12px; border-bottom: 1px solid #8d7c4f; position: relative; }
.city-heading::after { content: ''; position: absolute; bottom: -4px; left: calc(50% - 3px); width: 6px; height: 6px; background: #c8b88a; transform: rotate(45deg); box-shadow: 0 0 0 3px #1b1f27; }
.city-heading h2 { display: flex; align-items: center; gap: 12px; min-width: 0; max-width: 100%; font: 24px Georgia, 'Times New Roman', serif; letter-spacing: .14em; text-transform: uppercase; color: #e0cf9c; }
.city-title { min-width: 0; overflow-wrap: anywhere; text-align: center; }
svg.city-illustration { width: 48px; height: 48px; flex: none; border-radius: 50%; border: 1px solid #b7a36d; background: linear-gradient(#343b43, #161b23); box-shadow: 0 0 0 3px #15191f, 0 0 0 4px #635b43; }
.city-icon { font-size: 34px; line-height: 1; }
.city-note { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 9px 12px; border: 1px solid #687052; background: #303a2a40; color: #bdd09d; font-size: 13px; line-height: 1.5; }
.city-note > span:first-child:not(:last-child) { flex-shrink: 0; }
.city-note > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.city-note.flash { animation: noteBlink 1s ease-in-out infinite; }
@keyframes noteBlink { 0%, 100% { border-color: #687052; } 50% { border-color: #ffd54f; box-shadow: 0 0 8px #ffd54f66; } }
.city-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: start; gap: 0; margin: 16px 0 12px; }
.city-stat { min-width: 0; padding: 5px 10px; border: 0; border-right: 1px solid #77705b55; background: transparent; }
.city-stat:last-child { border-right: 0; }
.city-stat > summary { cursor: pointer; list-style: none; }
.city-stat > summary::-webkit-details-marker { display: none; }
.city-stat > summary:hover .city-stat-label { color: #f3e1af; text-decoration: underline dotted; }
.city-stat-label { display: block; margin-bottom: 5px; font-size: 11px; letter-spacing: .04em; color: #c4b78f; }
.city-stat-label::after { content: '⌄'; float: right; margin-left: 3px; color: #9b8c67; }
.city-stat[open] .city-stat-label::after { transform: rotate(180deg); }
.city-stat-extra { margin-top: 8px; padding-top: 7px; border-top: 1px solid #77705b55; }
.city-value { display: block; margin-bottom: 3px; font: 25px Georgia, 'Times New Roman', serif; color: #e0d6bb; }
.city-stat:nth-child(1) .city-value { color: #b3c88d; }
.city-stat:nth-child(2) .city-value { color: #d6b794; }
.city-stat:nth-child(3) .city-value { color: #e1c566; }
.city-stat:nth-child(4) .city-value { color: #93b8d0; }
.city-value small { font: 11px Arial, sans-serif; color: #a7a8ad; }
.production-amount { display: inline-flex; align-items: center; gap: .15em; white-space: nowrap; vertical-align: baseline; }
.production-icon { width: .9em; height: .9em; flex: none; fill: currentColor; }
.city-production-count { color: #e1cb8e; font-size: 13px; }
.city-detail { font-size: 12px; line-height: 1.35; color: #aaadb3; }
.city-progress { display: block; width: 100%; height: 4px; margin: 5px 0; border: 0; border-radius: 0; overflow: hidden; background: #0f1218; accent-color: #a9bc81; }
.city-progress::-webkit-progress-bar { background: #0f1218; }
.city-progress::-webkit-progress-value { background: #a9bc81; }
.city-progress::-moz-progress-bar { background: #a9bc81; }
.production-progress, .tech-progress { accent-color: #c5af70; }
.production-progress::-webkit-progress-value, .tech-progress::-webkit-progress-value { background: #c5af70; }
.production-progress::-moz-progress-bar, .tech-progress::-moz-progress-bar { background: #c5af70; }
.city-current-production { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 12px; padding: 10px 12px; border: 1px solid #766b4e; border-left: 3px solid #bda76e; background: linear-gradient(100deg, #3e3a2d66, #1d2129); }
#modal-box .city-current-production h3 { margin: 0; }
.city-production-name { font-size: 14px; }
.city-current-production .production-progress { flex: 1 1 80px; width: 100px; }
.city-production-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-left: auto; }
.city-resources, .city-built { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin: 4px 0; }
.city-resource { display: inline-block; padding: 3px 6px; border: 1px solid #75694d; border-radius: 1px; background: #282b30; font-size: 12px; }
.city-treasury { padding: 9px 0 1px; font-size: 12px; text-align: right; color: #b7aa86; }
.city-treasury b { color: #e1cb8e; }
.city-build-tabs { display: flex; gap: 0; margin: 8px 0 12px; border-bottom: 1px solid #6d644e; }
#modal-box:is(.city-dialog, .tech-dialog, .lobby-dialog, .leader-picker-dialog) .city-build-tabs button { flex: 1; border: 0; border-radius: 0; padding: 10px 8px; background: #22262e; font: 16px Georgia, 'Times New Roman', serif; text-transform: uppercase; letter-spacing: .12em; color: #aaaab0; box-shadow: none; }
#modal-box:is(.city-dialog, .tech-dialog, .lobby-dialog, .leader-picker-dialog) .city-build-tabs [aria-pressed="true"] { color: #eddbac; background: linear-gradient(0deg, #8d7a4230, transparent); box-shadow: inset 0 -3px #c0ab70; }
.city-grid.city-build-options { grid-template-columns: minmax(0, 1fr); gap: 0; }
#modal-box:is(.city-dialog, .tech-dialog, .lobby-dialog, .leader-picker-dialog) button { padding: 5px 8px; border: 1px solid #85754f; border-radius: 1px; background: linear-gradient(#3a3b36, #24272d); color: #e1d5b6; font-size: 12px; }
#modal-box:is(.city-dialog, .tech-dialog, .lobby-dialog, .leader-picker-dialog) button:hover:not(:disabled) { border-color: #d0b97d; background: #494536; }
#modal-box:is(.city-dialog, .tech-dialog, .lobby-dialog, .leader-picker-dialog) button:focus-visible, .city-dialog summary:focus-visible { outline: 2px solid #e0c67f; outline-offset: 3px; }
#modal-box:is(.city-dialog, .tech-dialog, .lobby-dialog, .leader-picker-dialog) button:disabled { opacity: .45; }
#modal-box:is(.city-dialog, .tech-dialog, .lobby-dialog, .leader-picker-dialog) > .modal-x { width: 28px; height: 28px; top: 0; margin-right: -8px; border-color: #ad9473; background: #6c303b; color: #ecdbc1; z-index: 3; }
.city-dialog .item { background: #252930; border-color: #666659; border-radius: 0; }
.city-dialog .city-build-options .items { gap: 7px; }
.city-dialog .city-build-options .item { display: grid; grid-template-columns: 50px minmax(0, 1fr) auto; gap: 12px; min-height: 74px; padding: 9px 12px; border: 1px solid #666659; border-radius: 0; background: linear-gradient(110deg, #30333a, #23272e); box-shadow: inset 3px 0 #94815480; }
.city-dialog .city-build-options .item:hover { border-color: #ac9764; background: linear-gradient(110deg, #3c3e42, #282d34); }
.city-dialog .city-build-options .item.current { border-color: #c4ab65; box-shadow: inset 3px 0 #d4bb78; }
.city-item-icon, .tech-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; border: 1px solid #d1bd80; background: radial-gradient(circle at 35% 25%, #68634c, #20252d 75%); box-shadow: 0 0 0 2px #1a1d23, inset 0 0 12px #0008; font-size: 27px; }
.city-item-icon .uicon, .tech-icon .uicon { width: 34px; height: 34px; margin: 0; }
.city-item-info { min-width: 0; }
.city-item-name, .tech-name { display: block; margin-bottom: 5px; font: 15px Georgia, 'Times New Roman', serif; letter-spacing: .06em; text-transform: uppercase; overflow-wrap: anywhere; color: #ded6c2; }
.city-dialog .city-item-info .meta { display: block; color: #b0b1b5; font-size: 12px; line-height: 1.4; }
.city-item-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; }
.city-build-time { display: flex; align-items: center; justify-content: flex-end; gap: 5px; color: #bab9b0; font-size: 12px; }
.city-build-time svg { width: 15px; height: 15px; fill: none; stroke: #b5a579; stroke-width: 1.5; }
.city-item-current { font-size: 12px; color: #e5cf90; }
.city-dialog .city-built-section { margin-top: 12px; padding-top: 2px; border-top: 1px solid #625b464f; }
#modal-box:is(.city-dialog, .tech-dialog, .lobby-dialog, .leader-picker-dialog) .modal-footer { margin: 10px 0 0; padding: 5px 0; bottom: -14px; background: #161a21; border-top: 1px solid #625b464f; }
@media (max-width: 760px) {
  #modal-box:is(.city-dialog, .tech-dialog, .lobby-dialog, .leader-picker-dialog) { width: 100vw; max-height: 100dvh; padding: 10px 12px; border: 1px solid #9e8c63; border-radius: 0; }
  .city-heading { padding: 0 22px 9px; gap: 5px; }
  .city-heading h2 { font-size: clamp(16px, 5vw, 20px); letter-spacing: .08em; gap: 10px; }
  .city-heading svg.city-illustration { width: 38px; height: 38px; }
  .city-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 12px 0 8px; row-gap: 7px; }
  .city-stat { padding: 4px 8px; }
  .city-stat:nth-child(even) { border-right: 0; }
  .city-stat:last-child { grid-column: 1 / -1; border-top: 1px solid #77705b33; padding-top: 7px; }
  .city-stat:last-child > summary { display: flex; align-items: center; gap: 12px; }
  .city-stat:last-child .city-stat-label { flex: 1; margin: 0; }
  .city-stat:last-child .city-value { margin: 0; font-size: 20px; }
  .city-value { font-size: 23px; }
  .city-production-actions { margin-left: 0; }
  .city-dialog .city-build-options .item { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 9px; min-height: 68px; padding: 8px; }
  .city-item-icon { width: 38px; height: 38px; font-size: 23px; }
  .city-item-icon .uicon { width: 28px; height: 28px; }
  .city-item-name { font-size: 12px; letter-spacing: .03em; }
  .city-dialog .city-item-info .meta { font-size: 11px; }
  #modal-box:is(.city-dialog, .tech-dialog, .lobby-dialog, .leader-picker-dialog) .city-item-actions button { padding: 5px; font-size: 11px; white-space: normal; max-width: 100px; }
  .city-build-time { font-size: 11px; }
}
.tech-emblem { width: 44px; height: 44px; flex: none; padding: 6px; border: 1px solid #b7a36d; border-radius: 50%; background: #20252d; fill: none; stroke: #d7c695; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tech-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 18px 0 14px; }
.tech-summary > div { padding: 2px 14px; border-right: 1px solid #77705b55; min-width: 0; }
.tech-summary > div:last-child { border: 0; }
.tech-summary span { display: block; margin-bottom: 6px; color: #b7aa86; font-size: 11px; letter-spacing: .03em; }
.tech-summary strong { font: 26px Georgia, 'Times New Roman', serif; color: #c9d5df; }
.tech-summary small { font: 12px Arial, sans-serif; color: #adafb4; }
.tech-current { padding: 12px 14px; border: 1px solid #766b4e; border-left: 3px solid #bda76e; background: linear-gradient(100deg, #3e3a2d66, #1d2129); }
#modal-box .tech-current h3 { margin: 0 0 10px; font-size: 14px; letter-spacing: .03em; line-height: 1.5; }
.tech-current h3 span { color: #ece0be; }
.tech-progress-meta { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; color: #c0c1c4; font-size: 12px; }
.tech-progress { height: 5px; margin: 10px 0 0; }
.tech-help { margin: 10px 0 18px; color: #aaaeb6; font-size: 12px; line-height: 1.5; }
.tech-current .tech-help { margin: 0; }
.tech-dialog .tech-options { gap: 8px; }
.tech-dialog .tech-options .item { display: grid; grid-template-columns: 50px minmax(0, 1fr) auto; gap: 12px; min-height: 82px; padding: 12px; border: 1px solid #666659; border-radius: 0; background: linear-gradient(110deg, #30333a, #23272e); box-shadow: inset 3px 0 #94815480; }
.tech-dialog .tech-options .item:hover { border-color: #ac9764; background: linear-gradient(110deg, #3c3e42, #282d34); }
.tech-dialog .tech-options .item.current { border-color: #c4ab65; box-shadow: inset 3px 0 #d4bb78; }
.tech-info { min-width: 0; }
.tech-name { margin: 0 0 5px; font-weight: 400; }
.tech-cost { margin-bottom: 5px; font-size: 12px; color: #d3bf87; }
.tech-unlocks { color: #b0b1b5; font-size: 12px; line-height: 1.5; }
.tech-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; max-width: 120px; text-align: right; }
.tech-duration { color: #bcbdbf; font-size: 12px; }
.tech-status { padding: 4px 8px; border: 1px solid #8e7c4f; background: #61553640; color: #ebd699; font-size: 12px; }
.tech-default { color: #b7aa86; font-size: 10px; }
.tech-completed { margin-top: 18px; padding-top: 4px; border-top: 1px solid #625b464f; }
.tech-known { display: flex; flex-wrap: wrap; gap: 6px; }
.tech-known > span { padding: 5px 8px; border: 1px solid #6b634d; background: #25282d; color: #c8c4b8; font-size: 12px; }
.tech-empty { padding: 8px 0; color: #aaaeb6; font-size: 12px; }
@media (max-width: 760px) {
  .tech-heading .tech-emblem { width: 36px; height: 36px; }
  .tech-summary { margin: 14px 0; }
  .tech-summary > div { padding: 2px 7px; }
  .tech-summary span { font-size: 10px; line-height: 1.4; }
  .tech-summary strong { font-size: 23px; }
  .tech-summary small { font-size: 10px; }
  .tech-current { padding: 10px; }
  #modal-box .tech-current h3 { font-size: 13px; }
  .tech-dialog .tech-options .item { grid-template-columns: 38px minmax(0, 1fr); gap: 8px 10px; padding: 10px; }
  .tech-icon { width: 36px; height: 36px; font-size: 23px; align-self: start; }
  .tech-icon .uicon { width: 26px; height: 26px; }
  .tech-name { font-size: 13px; letter-spacing: .03em; }
  .tech-unlocks { font-size: 11px; }
  .tech-actions { grid-column: 2; max-width: none; flex-direction: row; flex-wrap: wrap; justify-content: space-between; align-items: center; text-align: left; }
  .tech-duration { font-size: 11px; }
}
.items { display: flex; flex-direction: column; gap: 4px; }
.item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: #273243; border: 1px solid #34425a; border-radius: 4px; padding: 5px 8px; font-size: 13.5px;
}
.item .meta { color: #9aa6b8; font-size: 12px; }
.item.current { border-color: #ffca28; }
.modal-footer { display: flex; justify-content: space-between; margin-top: 16px; gap: 8px; flex-wrap: wrap; }
.civ-choice { display: flex; gap: 14px; margin: 16px 0; flex-wrap: wrap; }
.civ-choice button { padding: 18px 24px; font-size: 17px; border-width: 3px; }
.rules { font-size: 13.5px; color: #b8c2d0; line-height: 1.5; }
.rules ul { padding-left: 18px; margin: 6px 0; }

.speed { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; }
.speed select { background: #3a4556; color: #fff; border: 1px solid #56637a; border-radius: 4px; padding: 5px; }
.move-avatar { position: absolute; top: -8px; right: -8px; width: 75%; height: 75%; border-radius: 50%; object-fit: cover; border: 1px solid #d5ad58; pointer-events: none; opacity: .8; }

.unit-badge.floating { position: absolute; z-index: 20; left: 0; top: 0; bottom: auto; will-change: transform; }
.cell.hit::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 4;
  animation: hit-flash .45s ease-out;
}
@keyframes hit-flash {
  0% { background: rgba(255, 82, 82, .85); }
  100% { background: rgba(255, 82, 82, 0); }
}
.busy #map { cursor: progress; }

.zoom { display: inline-flex; gap: 2px; }
.zoom button { padding: 6px 10px; font-weight: 700; }
.short, .mobile-only { display: none; }
.settings-speed { display: flex; gap: 6px; margin: 8px 0 4px; }
.settings-speed button { flex: 1; }
.settings-speed button.on { background: #2e7d32; border-color: #43a047; }
.settings-sound { display: grid; gap: 12px; padding: 14px; border: 1px solid #6d644e; background: #191e26; color: #c9c3b3; }
.settings-sound fieldset { display: grid; gap: 12px; min-width: 0; margin: 0; padding: 10px; border: 1px solid #6d644e; }
.settings-sound fieldset:disabled { opacity: .5; }
.sound-toggle { display: flex; align-items: center; gap: 8px; }
.settings-sound input { accent-color: #c5af70; }
.settings-sound input[type="range"] { width: 100%; min-width: 0; }
.settings-sound output { float: right; color: #e1cb8e; }
.settings-sound p { margin: 0; font-size: 12px; line-height: 1.5; }
#panel .attack-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
#panel .attack-list button { text-align: left; background: #5a2a2a; border-color: #a33; }

/* ---------- phones (portrait) ---------- */
@media (max-width: 760px) {
  :root { --bar: 56px; }
  body { height: 100dvh; }
  button { padding: 9px 8px; font-size: 14px; white-space: nowrap; }
  .zoom button { padding: 9px 10px; }
  .long, #status .lbl, .speed-label { display: none; }
  .brand { font-size: 13px; flex-basis: 90px; }
  .short { display: inline; }
  .desktop-only { display: none !important; }
  .mobile-only { display: inline-block; }
  #topbar { padding: 6px; gap: 6px; }
  #actions-menu summary { padding: 9px 6px; font-size: 13px; }
  #status {
    flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; gap: 12px; font-size: 13px;
    scrollbar-width: none;
  }
  #status::-webkit-scrollbar { display: none; }
  .progress { width: 50px; }
  .actions { gap: 4px; }
  .actions-dropdown { position: fixed; top: 54px; right: 6px; max-width: calc(100vw - 12px); }
  .actions #btn-end { flex: 1; min-width: 0; }
  .speed select { padding: 8px 0; font-size: 13px; width: 64px; }
  #map-wrap { padding: 4px; }
  #panel h2 { font-size: 16px; }
  #panel .btns button { flex: 1 1 auto; }
  #panel .unit-list li { padding: 8px 6px; }
  .hint .keys { display: none; }
  #modal { align-items: stretch; }
  #modal-box { width: 100vw; max-height: 100dvh; border-radius: 0; border: 0; padding: 14px 12px 24px; }
  .city-grid { grid-template-columns: 1fr; gap: 0; }
  .item { padding: 8px; font-size: 14px; }
  .item button { flex-shrink: 0; }
  .modal-footer { position: sticky; bottom: -24px; background: #1f2835; padding: 10px 0; margin-bottom: -10px; }
  .modal-footer .esc-hint { display: none; }
  .civ-choice button { flex: 1 1 100%; }
}

/* ---------- phones (landscape) ---------- */
@media (max-height: 520px) and (min-width: 761px) {
  .brand { font-size: 14px; flex-basis: 120px; }
  #topbar { padding: 4px 8px; gap: 10px; }
  #status { font-size: 12px; gap: 4px 10px; }
  #modal-box { max-height: 100dvh; width: 100vw; border-radius: 0; }
}

.irrig { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.irrig path { stroke: #4fc3f7; stroke-width: 7; fill: none; opacity: .85; }
.road { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
.road-edge { stroke: #4e342e; stroke-width: 20; stroke-linecap: round; fill: none; }
.road-fill { stroke: #a1887f; stroke-width: 13; stroke-linecap: round; fill: none; }
.road-edge-dot { fill: #4e342e; }
.road-fill-dot { fill: #a1887f; }
#btn-end.ready { animation: end-pulse 1.4s ease-in-out infinite; }
@keyframes end-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(102, 187, 106, .0); }
  50% { box-shadow: 0 0 0 4px rgba(102, 187, 106, .65); }
}

/* ---------- auto mode ---------- */
#btn-auto.on { background: #8e2b2b; border-color: #c62828; }
#auto-menu {
  position: fixed; z-index: 60; width: 280px; max-width: calc(100vw - 12px);
  background: #1f2835; border: 1px solid #3a475b; border-radius: 8px; padding: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5); display: flex; flex-direction: column; gap: 6px;
}
#auto-menu.hidden { display: none; }
#auto-menu .menu-title { font-weight: 700; padding: 2px 4px 4px; }
#auto-menu button { text-align: left; white-space: normal; display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; }
#auto-menu button span { font-size: 12px; color: #a9b4c4; }
#auto-menu button.cancel { align-items: center; }
#panel .feed { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13px; }
#panel .feed li { padding: 3px 0; border-bottom: 1px solid #253042; line-height: 1.35; }
#panel .feed li .swatch { margin-right: 6px; vertical-align: -1px; }
#panel .feed li.turn-mark { color: #8b95a5; text-align: center; border-bottom: 0; padding-top: 6px; }
#panel .feed .good { color: #81c784; }
#panel .feed .bad { color: #ef9a9a; }
body.auto #panel { max-height: none; flex: 1; }
@media (max-width: 760px) {
  .actions #btn-end { overflow: hidden; text-overflow: ellipsis; }
}
#panel .feed .cnt { color: #ffd54f; }
.unit-badge .lvl { position: absolute; top: -7px; left: -5px; font-size: 10px; color: #ffd54f; text-shadow: 0 0 2px #000, 0 0 2px #000; font-weight: 700; }
@keyframes unit-blink { 50% { opacity: .3; } }
.unit-badge.blink { animation: unit-blink 1s ease-in-out infinite; }
.players-choice { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.players-choice button { min-width: 36px; }
.players-choice button.on { background: #2e7d32; border-color: #66bb6a; }
.tech-link { cursor: pointer; text-decoration: underline dotted; }
.tech-link:hover { color: #ffe082; }
#modal-box .good { color: #81c784; }
.uicon { width: 1.35em; height: 1.35em; vertical-align: -0.3em; object-fit: contain; }
.unit-badge .uicon { width: 100%; height: 100%; margin: 0; }
.cell .res { position: absolute; right: 2px; top: 2px; width: 46%; height: 46%; z-index: 1; pointer-events: none;
  display: flex; align-items: center; justify-content: center; animation: res-glint 27s linear infinite; }
.cell .res .uicon { width: 100%; height: 100%; margin: 0; vertical-align: 0; }
.cell .res::after { content: ''; position: absolute; inset: -20%; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 215, 64, .9) 0%, rgba(255, 193, 7, .45) 40%, rgba(255, 193, 7, 0) 70%);
  opacity: 0; animation: inherit; animation-name: res-halo; }
@keyframes res-glint {
  0%, 96%, 100% { filter: drop-shadow(0 0 1px rgba(0, 0, 0, .8)); transform: scale(1); }
  98% { filter: drop-shadow(0 0 5px #ffd740) drop-shadow(0 0 2px #fff59d) brightness(1.5) sepia(.6) saturate(2); transform: scale(1.18); }
}
@keyframes res-halo { 0%, 96%, 100% { opacity: 0; } 98% { opacity: 1; } }
.res-chip .uicon { width: 1.2em; height: 1.2em; }
.res-chip.off { opacity: .3; filter: grayscale(1); }
#modal-box .bad { color: #e57373; }

/* Leader dialog */
.leader { display: flex; gap: 18px; align-items: flex-start; position: relative; }
.leader.signal-lost::after {
  content: ''; position: absolute; top: 0; left: 0; width: clamp(220px, 30vmin, 480px); aspect-ratio: 1 / 1; height: auto;
  border-radius: 6px; pointer-events: none; mix-blend-mode: screen; overflow: hidden;
  background:
    repeating-linear-gradient(var(--sig-angle, 115deg),
      rgba(255, 64, 96, .22) 0 5px, transparent 5px 13px,
      rgba(64, 224, 255, .18) 13px 19px, transparent 19px 31px,
      rgba(255, 220, 80, .16) 31px 37px, transparent 37px 54px),
    repeating-linear-gradient(calc(var(--sig-angle, 115deg) + 90deg), rgba(255, 255, 255, .07) 0 2px, transparent 2px 5px);
  background-size: 220% 220%, 100% 5px;
  animation: signalStripes .9s linear infinite, signalFlicker .16s steps(1) infinite;
}
@keyframes signalStripes {
  from { background-position: 0 0, 0 0; }
  to { background-position: -220px 110px, 0 10px; }
}
@keyframes signalFlicker {
  0% { filter: hue-rotate(var(--sig-hue, 0deg)); }
  25% { filter: hue-rotate(calc(var(--sig-hue, 0deg) + 100deg)) brightness(1.5); }
  50% { filter: hue-rotate(calc(var(--sig-hue, 0deg) + 200deg)) saturate(2.2); }
  75% { filter: hue-rotate(calc(var(--sig-hue, 0deg) + 300deg)) brightness(.65); }
  100% { filter: hue-rotate(var(--sig-hue, 0deg)); }
}
.leader-portrait { width: clamp(220px, 30vmin, 480px); height: auto; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 6px; border: 3px solid #8d6e63; flex: none; }
.leader-portrait.ph { display: flex; align-items: center; justify-content: center; font-size: 80px; font-weight: 700; color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.7); }
.leader-body { flex: 1; min-width: 0; align-self: stretch; display: flex; flex-direction: column; }
.leader-body .leader-options { margin-top: auto; }
.leader-title { color: #9aa6b8; margin-bottom: 8px; }
.leader-speech { font-size: 17px; line-height: 1.5; font-style: italic; margin: 10px 0 18px; }
.leader-options { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; font-size: 16px; }
.hint-speech { font-style: normal; font-size: 15px; }
.hint-speech .keys { color: #9aa6b8; }
.pseudo { color: #81d4fa; cursor: pointer; border-bottom: 1px dashed currentColor; }
.pseudo:hover { color: #b3e5fc; }
.pseudo.off { color: #6b7686; cursor: default; }
.leader-note { color: #9aa6b8; font-size: 13px; margin-top: -6px; }
.trade-cols { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 4px; }
.trade-cols > div { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 160px; }
.trade-h { color: #9aa6b8; font-size: 13px; font-style: normal; }
.resdeal-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tech-pick { padding: 3px 10px; border: 1px solid #3a4556; border-radius: 14px; cursor: pointer; font-size: 14px; }
.tech-pick:hover { border-color: #81d4fa; }
.tech-pick.on { background: #1e4f6e; border-color: #81d4fa; color: #fff; }
@media (max-width: 760px) {
  .leader { flex-direction: column; align-items: center; text-align: center; }
  .leader-portrait { width: min(330px, 100%); height: auto; aspect-ratio: 1 / 1; }
  .leader.signal-lost::after { width: min(330px, 100%); aspect-ratio: 1 / 1; height: auto; left: 50%; transform: translateX(-50%); }
  .leader-options { align-items: center; }
}

/* Auth form */
#modal-box.auth-dialog { width: min(380px, 96vw); }
.auth-form { display: flex; flex-direction: column; gap: .6rem; margin-top: 10px; }
.auth-form input { padding: 8px 10px; font-size: 14px; border: 1px solid #6d644e; border-radius: 1px; background: #12161d; color: #e3dfd3; }
.auth-form input:focus { outline: 1px solid #c0ab70; }
.auth-form .btns { display: flex; gap: .5rem; justify-content: center; margin-top: .4rem; }
.auth-form .btns .primary { flex: 1; }
.auth-error { color: #e09a8f; font-size: 12px; text-align: center; }
.auth-switch { text-align: center; font-size: 12px; }
.auth-switch .pseudo { color: #d9c891; }
.auth-switch .pseudo:hover { color: #f0e2b4; }
.hidden { display: none !important; }
#games-screen { overflow: auto; padding: 32px 24px; height: 100%; min-height: 0; background: radial-gradient(ellipse at 50% 0, #4b46332e, transparent 65%), #13171e; scrollbar-color: #8b8066 #1b1e25; }
.lobby-shell { position: relative; isolation: isolate; overflow: hidden; max-width: 1180px; margin: 0 auto; padding: 26px 30px; border: 1px solid #9e8c63; background: radial-gradient(ellipse at 50% 0, #282c34, transparent 70%), #171b22; box-shadow: 0 20px 80px #0008, inset 0 0 0 4px #15191f, inset 0 0 0 5px #655d4538; }
.lobby-shell::before, .lobby-shell::after {
  content: ''; position: absolute; inset: 5px; pointer-events: none;
  background-size: auto; background-repeat: no-repeat;
  mask-composite: intersect;
}
.lobby-shell::before {
  z-index: -2; background-image: url('../assets/intro/greek_on_map.png'); background-position: right -150px top;
  opacity: .24; filter: grayscale(.55);
  mask-image: linear-gradient(to right, transparent, #000 60%), linear-gradient(to bottom, #000 45%, transparent);
}
.lobby-shell::after {
  z-index: -1; background-image: url('../assets/intro/aztecs_dim.png'); background-position: left -150px top;
  mask-image: linear-gradient(to left, transparent, #000 60%), linear-gradient(to bottom, #000 45%, transparent);
}
.lobby-heading { position: relative; text-align: center; padding-bottom: 22px; border-bottom: 1px solid #8d7c4f; }
.lobby-heading::after { content: ''; position: absolute; bottom: -4px; left: calc(50% - 3px); width: 6px; height: 6px; background: #c8b88a; transform: rotate(45deg); box-shadow: 0 0 0 3px #1b1f27; }
.lobby-kicker { margin-bottom: 10px; color: #a99d7b; font-size: 10px; letter-spacing: .2em; text-transform: uppercase; }
.lobby-emblem { width: 52px; height: 52px; fill: none; stroke: #c8b88a; stroke-width: 1.2; }
.lobby-heading h1 { margin: 8px 0; font: 30px Georgia, 'Times New Roman', serif; color: #e0cf9c; letter-spacing: .12em; text-transform: uppercase; }
.lobby-heading p, .lobby-help { color: #aeb0b6; font-size: 12px; line-height: 1.6; }
.lobby-heading p { margin: 0; }
.lobby-toolbar, #preview-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.lobby-toolbar { align-items: flex-end; padding: 24px 0 20px; border-bottom: 1px solid #625b464f; }
.lobby-toolbar label { display: grid; gap: 8px; flex: 1 1 260px; min-width: 0; color: #c4b78f; font-size: 12px; }
.lobby-toolbar input { width: 100%; min-width: 0; margin: 0; padding: 10px 12px; border: 1px solid #6d644e; border-radius: 1px; background: #12161d; color: #e3dfd3; font: inherit; }
.lobby-toolbar input::placeholder { color: #8f939b; }
#games-screen button { min-height: 38px; padding: 9px 14px; border: 1px solid #85754f; border-radius: 1px; background: linear-gradient(#3a3b36, #24272d); color: #e1d5b6; font-size: 12px; white-space: normal; }
#games-screen button.primary { background: linear-gradient(#76633b, #4d432e); border-color: #bda76e; color: #faedca; }
#games-screen button#lobby-create, button.pulse-green { background: linear-gradient(#3f7d47, #2a5230); border-color: #63b26d; color: #eaffef; animation: lobby-create-pulse 1.6s ease-in-out infinite; }
@keyframes lobby-create-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99, 178, 109, 0); filter: brightness(1); }
  50% { box-shadow: 0 0 14px 3px rgba(99, 178, 109, .6); filter: brightness(1.18); }
}
#games-screen button:hover:not(:disabled) { border-color: #d0b97d; background: #494536; }
#games-screen button:focus-visible, #games-screen input:focus-visible { outline: 2px solid #e0c67f; outline-offset: 3px; }
.lobby-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 20px 0 12px; }
.lobby-section-heading h2 { margin: 0; font: 15px Georgia, 'Times New Roman', serif; letter-spacing: .09em; color: #c8b88a; }
#games-count { color: #a7a8ad; font-size: 11px; }
#games-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 14px; }
.game-card { display: flex; flex-direction: column; gap: 18px; min-width: 0; padding: 18px; border: 1px solid #666659; background: linear-gradient(120deg, #30333a, #23272e); box-shadow: inset 3px 0 #94815480; }
.game-card.owned { border-color: #c4ab65; box-shadow: inset 3px 0 #d4bb78; }
.game-card-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.game-emblem { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border: 1px solid #b7a36d; border-radius: 50%; background: radial-gradient(circle at 35% 25%, #68634c, #20252d 75%); box-shadow: 0 0 0 2px #1a1d23; }
.game-emblem svg { width: 30px; height: 30px; fill: none; stroke: #decb95; stroke-width: 1.2; stroke-linejoin: round; }
.game-card-title { flex: 1; min-width: 0; }
.game-card-title h3 { margin: 0 0 6px; font: 17px Georgia, 'Times New Roman', serif; color: #e1d7bd; letter-spacing: .04em; overflow-wrap: anywhere; }
.game-access { color: #b4b3ad; font-size: 11px; }
.game-badge { padding: 4px 7px; border: 1px solid #8e7c4f; color: #e5cf90; background: #61553640; font-size: 10px; }
.game-badge.full { border-color: #766064; color: #c2a5a6; background: #50303940; }
.game-stats { display: grid; grid-template-columns: minmax(0, .65fr) minmax(0, 1fr); gap: 12px; padding: 12px 0; border-top: 1px solid #77705b55; border-bottom: 1px solid #77705b55; margin-top: auto; }
.game-stats span { display: block; color: #b7aa86; font-size: 11px; margin-bottom: 7px; }
.game-stats strong { font: 26px Georgia, 'Times New Roman', serif; color: #e0d6bb; }
.game-stats > div:last-child strong { color: #b3c88d; }
.game-seats-line { display: flex; align-items: flex-start; gap: 8px; }
.game-seats-line > strong { flex: none; }
.game-avatars { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; flex: 1; min-width: 0; }
.game-stats .game-avatar { display: inline-flex; position: relative; flex: none; width: 32px; height: 32px; margin: 0; border: 1px solid #b7a36d; border-radius: 50%; background: #20252d; }
.game-avatar img, .game-avatar > span { display: block; width: 100%; height: 100%; margin: 0; border-radius: 50%; object-fit: cover; }
.game-avatar > span { display: grid; place-items: center; color: #e0cf9c; font-size: 14px; }
.game-avatar.human::after { content: ''; position: absolute; right: -1px; bottom: -1px; width: 7px; height: 7px; border: 1px solid #15191f; border-radius: 50%; background: #a9c88c; }
.game-avatar.current-player { box-shadow: 0 0 0 2px #e0cf9c; }
.game-avatar.eliminated { opacity: .5; filter: grayscale(1); }
.game-card > button { width: 100%; }
.lobby-empty { grid-column: 1 / -1; padding: 34px 18px; border: 1px solid #6d644e; background: #20242b; text-align: center; }
.lobby-empty h3 { margin: 0 0 10px; font: 17px Georgia, 'Times New Roman', serif; color: #d8c99f; }
.lobby-empty p { margin: 0; font-size: 12px; color: #b0b1b5; }
.lobby-help { margin: 20px 0 0; text-align: center; }
@media (max-width: 760px) {
  #games-screen { padding: 12px; }
  .lobby-shell { padding: 18px 14px; }
  .lobby-heading h1 { font-size: clamp(22px, 6vw, 28px); letter-spacing: .08em; }
  .lobby-heading { padding-bottom: 18px; }
  .lobby-toolbar { gap: 10px; padding: 20px 0 16px; }
  .lobby-toolbar label { flex-basis: 100%; }
  .lobby-toolbar button { flex: 1; }
  .lobby-section-heading { flex-wrap: wrap; margin-top: 18px; }
  .game-card { padding: 16px; }
}
#preview-controls { padding: 12px; }
body.preview #topbar, body.preview #side { display: none; }
body.preview main { height: calc(100% - 100px); }
.leader-list-name { display: block; margin-top: 4px; color: #d9c58e; font-size: 12px; }
#preview-leader { width: 40px; height: 40px; margin: 0; }
#preview-name { flex: 0 1 auto; min-width: 0; overflow-wrap: anywhere; }

#modal-box.leader-picker-dialog { width: min(800px, 96vw); }
.leader-picker-layout { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: 24px; margin-top: 24px; }
.leader-picker-preview { display: flex; flex-direction: column; align-items: center; gap: 9px; text-align: center; }
.leader-picker-preview video { width: 100%; aspect-ratio: 1; object-fit: cover; border: 2px solid #b7a36d; border-radius: 2px; }
.leader-picker-preview strong { font: 19px Georgia, 'Times New Roman', serif; color: #e0cf9c; }
.leader-picker-preview > span { color: #b7aa86; font-size: 12px; }
.leader-picker-fields { display: grid; gap: 14px; min-width: 0; align-content: start; }
.leader-picker-fields > p { margin: 0; font-size: 13px; line-height: 1.5; }
.leader-gender-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; min-width: 0; margin: 0; padding: 0; border: 0; }
.leader-gender-options legend { margin-bottom: 10px; font-size: 13px; color: #c4b78f; }
.leader-option { display: flex; align-items: center; gap: 7px; padding: 8px; border: 1px solid #6d644e; background: #242830; min-width: 0; cursor: pointer; }
.leader-option:has(input:checked) { border-color: #d1ba78; background: #49432f; }
.leader-option input { margin: 0; flex: none; accent-color: #c5af70; }
.leader-option img { width: 40px; height: 48px; object-fit: cover; flex: none; border: 1px solid #8d7c4f; }
.leader-option > span { min-width: 0; overflow-wrap: anywhere; font-size: 12px; }
.leader-option small { display: block; margin-top: 5px; color: #c4b78f; font-size: 11px; }
.leader-name-label { display: grid; gap: 8px; color: #c4b78f; font-size: 13px; }
.leader-name-label input { min-width: 0; width: 100%; padding: 10px; border: 1px solid #6d644e; border-radius: 1px; background: #12161d; color: #e3dfd3; font: inherit; }
.leader-picker-dialog input:focus-visible { outline: 2px solid #e0c67f; outline-offset: 3px; }
.leader-picker-fields .leader-picker-help { font-size: 12px; color: #aaaeb6; }
#leader-picker-error { color: #e7a3a1; }
.leader-picker-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.leader-picker-actions button { flex: 1; }
#modal-box .leader-picker-actions button[type="submit"] { background: linear-gradient(#76633b, #4d432e); border-color: #bda76e; color: #faedca; }
@media (max-width: 760px) {
  .leader-picker-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; margin-top: 18px; }
  .leader-picker-preview video { width: 140px; }
  .leader-picker-preview strong { font-size: 17px; }
  .leader-picker-fields { gap: 12px; }
  .leader-option { padding: 6px; gap: 5px; }
  .leader-option img { width: 34px; height: 44px; }
}
#modal-box.lobby-dialog { width: min(560px, 96vw); }
.lobby-dialog form { margin-top: 22px; color: #c4b78f; font-size: 13px; }
.lobby-dialog input, .lobby-dialog select { min-width: 0; max-width: 100%; border: 1px solid #6d644e; border-radius: 1px; background: #12161d; color: #e3dfd3; }
#game-password-form input { width: 100%; padding: 10px; font: inherit; }
#game-password-error { color: #e7a3a1; }
#create-game-form { display: grid; gap: 12px; }
#create-game-form label { display: grid; gap: 4px; }
#create-game-form input, #create-game-form select { padding: 8px; font: inherit; }
