:root {
  color-scheme: dark;
  --ground: #211c19;
  --cream: #f4e7c8;
  --gold: #d6b77b;
  --bronze: #9a794a;
  --paper: #e7d8b8;
  --ink: #30251c;
  --muted: #675944;
  --red: #6f2926;
  --line: #b6a17d;
  --display: Georgia, "Times New Roman", serif;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--ground);
  color: var(--cream);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: radial-gradient(ellipse at 50% 0, #3b3028, transparent 68%); }
button, input, select { font: inherit; }
button, summary, select { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid #4c85ad; outline-offset: 3px;
}
a { color: inherit; text-underline-offset: 3px; }
main { max-width: 1152px; margin: auto; padding: 0 32px 32px; }
.masthead { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 22px 0; }
.brand { display: inline-flex; align-items: center; gap: 12px; font: bold 25px var(--display); color: var(--cream); text-decoration: none; }
.crest { display: grid; place-items: center; height: 39px; width: 32px; padding-bottom: 3px; background: #792f2c; color: #f5d490; font-size: 28px; clip-path: polygon(0 0,100% 0,100% 72%,50% 100%,0 72%); }
.edition { font: small-caps 15px var(--display); color: var(--gold); letter-spacing: 1px; }
.edition i { margin: 0 5px; }
.hero { position: relative; isolation: isolate; overflow: hidden; display: flex; align-items: center; min-height: 208px; border: 1px solid var(--bronze); background: #39241f; }
.hero::before { content: ""; position: absolute; z-index: -2; inset: 0 0 0 25%; background: url("coastal-town.jpg") center 35% / cover no-repeat; }
.hero::after { content: ""; position: absolute; z-index: -1; inset: 0; background: linear-gradient(90deg, #39241f 16%, #39241ff2 34%, #39241fb8 48%, #39241f14 74%), linear-gradient(0deg,#30201666,transparent 45%); box-shadow: inset 0 0 0 5px #20140b30; }
.hero-copy { padding: 34px 42px; max-width: 58%; }
h1, h2, p { margin: 0; }
h1 { font: normal clamp(41px,5.5vw,68px)/1.05 var(--display); color: #ffefd2; letter-spacing: -.04em; }
.hero p { margin-top: 13px; color: #e4cfad; max-width: 420px; line-height: 1.55; }
h2 { font: bold 24px/1.18 var(--display); letter-spacing: -.025em; color: #492d21; }
.paper { color-scheme: light; color: var(--ink); background: linear-gradient(110deg,#efe3c9,#e4d3b0); border: 1px solid #b99c6b; box-shadow: inset 0 0 0 3px #fff4d844; padding: 22px 24px; min-width: 0; }
#entry { margin-top: 14px; }
#entry h2, .lower h2 { margin-bottom: 15px; }
#entry-online:not([hidden]) + #solo:not([hidden]) { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 18px; }
label, .hint, #file-count { font-size: 13px; color: var(--muted); }
label { display: block; margin-bottom: 5px; }
.actions, .controls { display: flex; align-items: center; gap: 8px; }
.actions input { min-width: 0; flex: 1; }
#nickname { max-width: 350px; }
input:not([type=checkbox]), select { border: 1px solid #aa9571; background: #f8efd9; color: var(--ink); border-radius: 2px; padding: 9px 12px; }
input::placeholder { color: #796c58; }
.button { display: inline-flex; align-items: center; justify-content: center; padding: 9px 15px; border: 1px solid #a18860; border-radius: 2px; background: #efdfbd; color: #452f21; box-shadow: inset 0 1px #fff4dc; font-size: 13px; font-weight: 650; min-height: 38px; }
.button:not(:disabled):hover { background: #f9ebce; border-color: #74552f; }
.button.primary { color: #fff2d7; background: var(--red); border-color: #9f7351; box-shadow: inset 0 1px #ad6555; }
.button.primary:not(:disabled):hover { background: #873830; }
.button.dark { background: #463a30; color: #fff0d3; border-color: var(--bronze); box-shadow: none; }
.button.dark:not(:disabled):hover { background: #594638; }
.button:disabled { opacity: .55; }
.check { display: inline-flex; align-items: center; gap: 5px; margin: 18px 0 0; }
input[type=checkbox] { accent-color: var(--red); }
#file-options { margin-top: 14px; font-size: 13px; }
#file-options .actions { margin: 10px 0; }
.match-strip { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 22px; border: 1px solid var(--bronze); border-top: 0; background: #332a24; }
#phase { color: #f6dd9d; font: bold 21px var(--display); }
#seats { margin-left: 14px; font-size: 13px; color: #dfd1ba; }
.leave { color: #e9d9bc; font-size: 13px; padding: 5px; }
#notice { border-left: 3px solid var(--gold); padding: 8px 12px; margin: 12px 0 0; color: #f1debd; background: #392f27; }
.columns { display: grid; grid-template-columns: minmax(0,1.35fr) minmax(0,1fr); gap: 14px; margin-top: 14px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.section-head > span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.roster { list-style: none; margin: 0; padding: 0; }
.roster li { display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 7px 0; border-top: 1px solid #bcaa88; }
.roster .ribbon { display: grid; place-items: center; width: 26px; height: 33px; padding-bottom: 4px; flex: 0 0 auto; background: var(--seat-color,#80715b); color: white; font: bold 16px var(--display); clip-path: polygon(0 0,100% 0,100% 100%,50% 83%,0 100%); }
[data-seat="1"] { --seat-color: #3b5a80; }
[data-seat="2"] { --seat-color: #903c33; }
[data-seat="3"] { --seat-color: #446745; }
[data-seat="4"] { --seat-color: #856226; }
.member-info { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.member-name { display: block; font-size: 14px; font-weight: 650; }
.member-meta { display: block; color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); font: italic 15px var(--display); }
.ready-mark { font-size: 12px; color: #285832; font-weight: 700; white-space: nowrap; }
.roster .button { padding: 5px 9px; min-height: 32px; font-size: 12px; }
.gallery { max-height: 210px; overflow: auto; margin-top: 9px; }
.target-seat { display: flex; align-items: center; gap: 9px; margin: 10px 0 0; }
.target-seat select { font-size: 12px; padding: 5px; }
.arsenal { margin-top: 14px; }
.civ-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 9px; margin-top: 14px; }
.civ { position: relative; display: flex; align-items: center; text-align: left; min-width: 0; gap: 11px; padding: 10px; border: 1px solid var(--line); background: #f2e6cb; color: var(--ink); border-radius: 2px; }
.civ[aria-pressed=true] { border: 2px solid #7b342c; padding: 9px; background: #f7e8c2; box-shadow: inset 0 -3px #7b342c; }
.civ:not(:disabled):hover { border-color: #7b342c; }
.civ img, .portrait { width: 40px; height: 40px; flex: 0 0 40px; image-rendering: pixelated; }
.portrait { display: grid; place-items: center; background: #644936; color: #f1da9c; font: 24px var(--display); border: 1px solid #aa8755; }
.civ strong, .civ small { display: block; }
.civ strong { font: bold 18px var(--display); }
.civ small { color: var(--muted); font-size: 11px; margin-top: 2px; }
#ready[aria-pressed=true] { border-color: #506749; background: #e0e3c7; color: #2e5137; }
#messages { min-height: 34px; max-height: 140px; overflow-y: auto; margin: 0 0 10px; font-size: 13px; overflow-wrap: anywhere; }
#messages:empty::before { content: "Henüz mesaj yok."; color: var(--muted); }
#messages p { margin-bottom: 3px; }
#chat-text, #invite { font-size: 13px; }
.match-stats { margin: 14px 0; }
.match-stats .section-head { align-items: center; gap: 10px; }
.match-stats label { margin: 0; }
#stats-time { font-size: 13px; color: var(--muted); }
.stats-scroll { overflow-x: auto; }
#stats-table { border-collapse: collapse; width: 100%; margin-top: 12px; font-size: 14px; font-variant-numeric: tabular-nums; }
#stats-table th, #stats-table td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: right; overflow-wrap: anywhere; }
#stats-table th:first-child { text-align: left; }
#stats-table tbody th { font-weight: normal; }
.feedback { font-size: 13px; color: #dfd1ba; }
.feedback p:not(:empty), #restart { display: block; margin-top: 12px; }
#error { color: #ffceb5; white-space: pre-line; }
#progress {
  --gold-fill: linear-gradient(to bottom, #f8e2a7 0 1px, var(--gold) 1px, #c59851 55%, #a87938 calc(100% - 1px), #80582a 0);
  --value-fill: var(--gold-fill);
  display: block;
  width: 100%;
  height: 20px;
  margin: 8px 0 18px;
  padding: 2px;
  appearance: none;
  -webkit-appearance: none;
  overflow: hidden;
  border: 1px solid var(--bronze);
  border-color: #a88a5b #725433 #695032 #aa8959;
  border-radius: 0;
  background-color: #35281e;
  box-shadow: inset 0 0 0 1px #211810, inset 0 2px 3px #17110c, 0 1px 0 #17120e;
}
#progress::-webkit-progress-bar { background: transparent; }
#progress::-webkit-progress-value { background: var(--value-fill); }
#progress::-moz-progress-bar { background: var(--value-fill); }
#progress:indeterminate {
  --value-fill: transparent;
  background-image: var(--gold-fill);
  background-origin: content-box;
  background-repeat: no-repeat;
  background-size: 25% 100%;
  animation: loading-sweep 1.8s ease-in-out infinite alternate;
}
@keyframes loading-sweep { from { background-position: left center; } to { background-position: right center; } }
@media (prefers-reduced-motion: reduce) {
  #progress:indeterminate { animation: none; background-position: center; }
}
@media (forced-colors: active) {
  #progress { forced-color-adjust: none; --gold-fill: linear-gradient(Highlight, Highlight); background-color: Canvas; border-color: CanvasText; box-shadow: none; }
}
.feedback:has(#progress:not([hidden])) + #lobby .match-strip { border-top: 1px solid var(--bronze); }
footer { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-top: 18px; border-top: 1px solid #5d4c3b; padding-top: 14px; font-size: 12px; color: #c3b294; }
#diagnostics { flex: 1; min-width: 0; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; overflow: auto; font-size: 11px; }
#game, #viewport, .battlefield, #canvas { position: fixed; inset: 0; height: 100%; width: 100%; overflow: hidden; background: black; }
#game { display: flex; flex-direction: column; }
#viewport { position: relative; inset: auto; flex: 1; height: auto; min-height: 0; }
#viewport iframe { display: block; width: 100%; height: 100%; border: none; }
#canvas { display: block; touch-action: none; outline: 0; }
body.playing { overflow: hidden; overscroll-behavior: none; }
#connection-status { position: fixed; top: 8px; left: 50%; transform: translateX(-50%); z-index: 5; max-width: 90vw; padding: 8px 14px; background: #231c19; color: var(--cream); border: 1px solid var(--bronze); }
@media (max-width: 760px) {
  main { padding: 0 16px 24px; } .masthead { padding: 15px 0; }
  .hero { min-height: 160px; } .hero-copy { padding: 22px; max-width: 80%; }
  .hero p { font-size: 13px; } .paper { padding: 17px; }
  .columns { grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; }
  .civ-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .controls { flex-wrap: wrap; }
}
@media (max-width: 580px) {
  main { padding: 0 10px 18px; }
  .brand { font-size: 21px; gap: 7px; } .edition { font-size: 11px; letter-spacing: 0; }
  .hero-copy { max-width: 88%; } .hero::after { background: linear-gradient(90deg,#39241ff5,#39241fa8 65%,#39241f38); }
  .hero::before { inset: 0; background-size: auto 235%; background-position: 65% 35%; }
  #lobby.seated { display: flex; flex-direction: column; }
  #lobby.seated .arsenal { order: 1; }
  #lobby.seated .columns { order: 2; }
  .columns { grid-template-columns: 1fr; } .match-strip { padding: 12px; }
  #seats { display: block; margin: 2px 0 0; }
  #entry .actions { flex-wrap: wrap; } #nickname { flex-basis: 100%; max-width: none; }
  h2 { font-size: 22px; } .civ { gap: 7px; } .civ strong { font-size: 16px; }
  .civ img, .portrait { width: 32px; height: 32px; flex-basis: 32px; }
}

#command-notice { position: absolute; top: 12%; left: 12px; max-width: calc(100% - 24px); color: white; font: bold 14px Georgia, serif; text-shadow: 1px 1px 2px black, -1px -1px 2px black; pointer-events: none; }
#credential { padding: 9px 14px; border: 1px solid var(--bronze); background: #282019; color: var(--cream); }
#credential::backdrop { background: transparent; }
#credential label { margin: 0 0 4px; color: inherit; }
#credential input { width: min(260px, 75vw); }

#replay-import { margin-top: 14px; }
.replay-links { padding: 10px 16px; background: #31271f; border: 1px solid var(--bronze); }
#replay-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 5px 12px; background: #2e251e; color: var(--cream); font-size: 13px; }
#replay-controls .button { padding: 4px 9px; }
#replay-controls select { width: auto; padding: 3px 6px; }
#replay-controls a:last-child { margin-left: auto; }
#replay-position { font-variant-numeric: tabular-nums; }
