:root {
  --bg: #070606;
  --fg: #e7e5e4;
  --muted: #a8a29e;
  --olcek: 1;
  --panel: rgba(10, 10, 10, 0.94);
  --kenar: #44403c;
  --vurgu: #fde68a;
  --pixel-font: 'Press Start 2P', monospace;
  --vt-font: 'VT323', monospace;
}

* {
  box-sizing: border-box;
}

@supports not selector(::-webkit-scrollbar) {
  * {
    scrollbar-width: thin;
    scrollbar-color: #44403c #0c0a09;
  }
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

*::-webkit-scrollbar-track {
  background: #0c0a09;
  border-left: 1px solid #1c1917;
}

*::-webkit-scrollbar-thumb {
  background: #44403c;
  border-radius: 999px;
  border: 1px solid #1c1917;
}

*::-webkit-scrollbar-thumb:hover {
  background: #fde68a;
}

*::-webkit-scrollbar-corner {
  background: #0c0a09;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 system-ui, -apple-system, sans-serif;
}

.kng-shell {
  max-width: 1360px;
  margin: 0 auto;
  padding: 10px 14px 16px;
}

.kng-wrap {
  background: #0c0a09;
  border: 2px solid #292524;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.65);
}

.kng-stage {
  position: relative;
  width: 100%;
  height: min(68vh, 620px);
  min-height: 430px;
  background: #090d1a;
  overflow: hidden;
}

#sahne.kng-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: none;
  cursor: grab;
}
#sahne.kng-canvas:active { cursor: grabbing; }

/* Üst Sol HUD (.kng-hud) */
#ust-cubuk.kng-hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: auto;
  max-width: calc(100% - 320px);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  padding: 6px 11px;
  background: rgba(10, 10, 10, 0.86);
  border: 1px solid #44403c;
  border-radius: 6px;
  font-family: var(--pixel-font);
  font-size: calc(9px * var(--olcek));
  line-height: 1.5;
  color: #d6d3d1;
  pointer-events: auto;
  z-index: 3;
}

.kng-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
  animation: kng-blink 1.6s infinite;
}
@keyframes kng-blink { 50% { opacity: 0.35; } }

.kng-live { color: #e7e5e4; letter-spacing: 0.04em; }
.kng-sep { color: #57534e; }
.kng-clock { color: #fde68a; font-variant-numeric: tabular-nums; }
.kng-weather, .kng-moon {
  font-family: system-ui, sans-serif;
  font-size: calc(12px * var(--olcek));
  font-weight: 600;
  color: #cbd5e1;
}
.kng-target {
  font-family: system-ui, sans-serif;
  font-size: calc(12px * var(--olcek));
  font-weight: 700;
  color: #7dd3fc;
}

#gozlem-rozet.kng-office {
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
}
#gozlem-rozet[data-durum="ACIK"] { background: rgba(34, 197, 94, 0.2); color: #86efac; border: 1px solid #22c55e; }
#gozlem-rozet[data-durum="KAPALI"] { background: rgba(239, 68, 68, 0.2); color: #fca5a5; border: 1px solid #ef4444; }
#gozlem-rozet[data-durum="GUNDUZ"] { background: rgba(250, 204, 21, 0.16); color: #fde68a; border: 1px solid #eab308; }

/* Üst Sağ HUD: Kat seçici (1·2·3·4) ve Kim nerede */
.kng-hud-r {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  z-index: 3;
}

#kat-secici {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  background: rgba(10, 10, 10, 0.88);
  border: 1px solid #44403c;
  border-radius: 6px;
  font-family: var(--pixel-font);
  font-size: calc(9px * var(--olcek));
}
#kat-secici .etiket, #kat-secici .ayrac { color: #78716c; }
#kat-secici button {
  min-height: 28px;
  padding: 3px 8px;
  font-family: var(--pixel-font);
  font-size: calc(9px * var(--olcek));
  color: #e7e5e4;
  background: #1c1917;
  border: 1px solid #44403c;
  border-radius: 4px;
  cursor: pointer;
}
#kat-secici button:hover { background: #292524; border-color: #fde68a; }
#kat-secici button[aria-pressed="true"] {
  background: #292524;
  border-color: #fde68a;
  color: #fde68a;
  box-shadow: 0 0 8px rgba(253, 230, 138, 0.25);
}
#kat-secici .sayi { margin-left: 4px; color: #a8a29e; font-family: system-ui, sans-serif; font-size: 11px; }
#kat-secici .sayi::before { content: "("; }
#kat-secici .sayi::after { content: ")"; }

#liste {
  width: min(280px, calc(100vw - 28px));
  max-height: 320px;
  overflow: auto;
  background: rgba(10, 10, 10, 0.92);
  border: 1px solid #44403c;
  border-radius: 6px;
  font-size: calc(13px * var(--olcek));
}
#liste summary {
  padding: 7px 11px;
  cursor: pointer;
  font-family: var(--pixel-font);
  font-size: calc(8.5px * var(--olcek));
  color: #fde68a;
}
#liste ul, #kart ul { list-style: none; margin: 0; padding: 0; }
#liste button {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 8px;
  width: 100%;
  padding: 6px 11px;
  font: inherit;
  text-align: left;
  color: var(--fg);
  background: none;
  border: 0;
  border-top: 1px solid #1c1917;
  cursor: pointer;
}
#liste button:hover { background: #1c1917; }
#liste .emoji { grid-row: span 2; font-size: 1.2em; }
#liste .ad { font-weight: 700; color: #f5f5f4; }
#liste .nerede { color: #a8a29e; font-size: 0.9em; }

/* Sağ Alt Kontroller (.kng-zoom) */
#yakinlastirma.kng-zoom {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  gap: 4px;
  z-index: 3;
}
#yakinlastirma.kng-zoom button {
  min-width: 32px;
  height: 30px;
  padding: 0 8px;
  background: rgba(10, 10, 10, 0.88);
  color: #e7e5e4;
  border: 1px solid #44403c;
  border-radius: 5px;
  font-family: var(--pixel-font);
  font-size: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#yakinlastirma.kng-zoom button:hover { background: #292524; border-color: #a8a29e; }
#ses-dugmesi[aria-pressed="true"] { border-color: #22c55e; color: #86efac; background: rgba(20, 83, 45, 0.7); }

.kng-hint {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 10px;
  background: rgba(10, 10, 10, 0.78);
  border: 1px solid #292524;
  border-radius: 4px;
  color: #a8a29e;
  font-family: var(--pixel-font);
  font-size: 8px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 2;
}

/* Karakter ve Oda Kartları (.kng-card / .kng-room) */
#kart {
  position: absolute;
  left: 10px;
  bottom: 10px;
  width: min(350px, calc(100% - 20px));
  max-height: calc(100% - 70px);
  overflow: auto;
  padding: 12px 14px;
  background: rgba(10, 10, 10, 0.96);
  border: 2px solid #fde68a;
  border-radius: 8px;
  box-shadow: 4px 4px 0 #000;
  color: #e7e5e4;
  font-size: calc(13px * var(--olcek));
  z-index: 4;
}
#kart[data-tur="oda"] {
  left: auto;
  right: 10px;
  bottom: 48px;
  border-color: #7dd3fc;
}
#kart[hidden] { display: none; }

.kng-card-x {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: 0;
  color: #a8a29e;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}
.kng-card-x:hover { color: #fff; }

.kng-card-head { display: flex; gap: 10px; align-items: center; }
.kng-portrait {
  width: 40px;
  height: 56px;
  image-rendering: pixelated;
  background: #1c1917;
  border: 1px solid #44403c;
  border-radius: 4px;
  flex-shrink: 0;
}
.kng-card-tag {
  font-family: var(--pixel-font);
  font-size: 8px;
  color: #a8a29e;
  letter-spacing: 0.08em;
}
.kng-card-name {
  margin: 3px 24px 2px 0;
  font-family: var(--pixel-font);
  font-size: 11px;
  line-height: 1.35;
}
.kng-card-role { margin: 0; font-size: 11px; color: #a8a29e; }
.kng-card-state {
  margin: 8px 0 6px;
  font-family: var(--pixel-font);
  font-size: 9px;
  color: #86efac;
}

.kng-task {
  margin: 7px 0;
  padding: 7px 9px;
  background: #141210;
  border: 1px solid #292524;
  border-left: 3px solid #f59e0b;
  border-radius: 4px;
}
.kng-task-lbl {
  font-family: var(--pixel-font);
  font-size: 8px;
  color: #fbbf24;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}
.kng-task-title { font-size: 11.5px; color: #fde68a; line-height: 1.35; margin-bottom: 5px; font-weight: 600; }
.kng-task-stages { display: flex; flex-wrap: wrap; gap: 4px; }
.kng-task-stages span {
  font-family: var(--pixel-font);
  font-size: 7px;
  padding: 2px 5px;
  border-radius: 3px;
  background: #1c1917;
  color: #57534e;
  border: 1px solid #292524;
}
.kng-task-stages span.done { color: #86efac; border-color: #14532d; background: #052e16; }
.kng-task-stages span.now { color: #fde68a; border-color: #f59e0b; background: #451a03; }

.kng-card-bio { margin: 6px 0; font-size: 12px; line-height: 1.45; color: #d6d3d1; }
.kng-card-say {
  margin: 6px 0 0;
  padding: 6px 8px;
  background: #1c1917;
  border-left: 2px solid #fde68a;
  font-size: 12px;
  color: #fef3c7;
  font-style: italic;
  cursor: pointer;
}
.kng-card-say:hover { background: #292524; }

.kng-bars { margin-top: 8px; }
.kng-bar {
  display: grid;
  grid-template-columns: 78px 1fr;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-family: var(--pixel-font);
  font-size: 7.5px;
  color: #a8a29e;
}
.kng-bar-track {
  height: 6px;
  background: #1c1917;
  border: 1px solid #292524;
  border-radius: 3px;
  overflow: hidden;
}
.kng-bar-track i { display: block; height: 100%; }

#kart h3 {
  margin: 10px 0 4px;
  font-family: var(--pixel-font);
  font-size: 8px;
  color: #a8a29e;
  letter-spacing: 0.05em;
}
#kart .mini.kng-mini {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 260 / 150;
  margin: 6px 0;
  background: #0c0a09;
  border: 1px solid #292524;
  border-radius: 4px;
  image-rendering: pixelated;
}
.kng-room-sub { margin: 4px 0 6px; font-size: 11.5px; color: #a8a29e; line-height: 1.35; }
.kng-room-who li { padding: 3px 4px; border-radius: 3px; font-size: 12px; }
.kng-room-who li:hover { background: #1c1917; color: #fde68a; }

/* Konuşma Balonları */
#balonlar.kng-bubbles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }
.balon {
  position: absolute;
  transform: translate(-50%, -100%);
  width: max-content;
  max-width: min(310px, calc(100vw - 24px));
  padding: 7px 11px;
  background: #fffef7;
  color: #0f172a;
  border: 2px solid #0f172a;
  border-radius: 6px;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.75);
  font-family: var(--vt-font);
  font-size: calc(19px * var(--olcek));
  line-height: 1.15;
  pointer-events: auto;
  cursor: pointer;
}
.balon::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  transform: translateX(-50%);
  border-width: 7px 7px 0;
  border-style: solid;
  border-color: #0f172a transparent transparent;
}
.balon-baslik {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 2px;
  font-family: var(--pixel-font);
  font-size: 8.5px;
  color: #b45309;
}
.balon-sayac { color: #64748b; margin-left: auto; }
.balon-ses {
  padding: 1px 5px;
  font-size: 10px;
  background: #fef3c7;
  border: 1px solid #d97706;
  border-radius: 3px;
  cursor: pointer;
}
.balon-metin { margin: 0; color: #0f172a; }
.balon.baska-kat {
  left: 50%;
  top: 52px;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.94);
  color: #f8fafc;
  border: 1px solid #fde68a;
  font-size: calc(17px * var(--olcek));
}
.balon.baska-kat .balon-kisi { color: #fde68a; font-weight: 700; }
.balon.baska-kat::after { display: none; }

/* Yatay Kadro Çubuğu (.kng-staff) */
.kng-staff {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 9px 12px;
  background: #141210;
  border-top: 2px solid #292524;
  align-items: center;
}
.kng-staff-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  background: #1c1917;
  border: 1px solid #292524;
  border-radius: 5px;
  color: #e7e5e4;
  font-family: inherit;
  font-size: 11.5px;
  cursor: pointer;
}
.kng-staff-item:hover, .kng-staff-item.is-active {
  border-color: #fde68a;
  background: #292524;
}
.kng-staff-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.kng-staff-name { font-weight: 700; }
.kng-staff-state { color: #78716c; font-size: 10.5px; }
.kng-credit {
  margin-left: auto;
  font-family: var(--pixel-font);
  font-size: 8px;
  color: #57534e;
  text-decoration: none;
}
.kng-credit:hover { color: #a8a29e; }

/* Alt İki Sütun: Gözlemevi Günlüğü (.kng-log) + İzleyici Sohbeti (.kng-chat) */
.kng-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 2px solid #292524;
  background: #0c0a09;
}
.kng-log {
  background: #0c0a09;
  font-family: var(--vt-font);
  font-size: calc(17px * var(--olcek));
}
.kng-log details { margin: 0; }
.kng-log-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: #141210;
  border-bottom: 1px solid #1c1917;
  font-family: var(--pixel-font);
  font-size: 9px;
  color: #fde68a;
  letter-spacing: 0.06em;
  cursor: pointer;
  list-style: none;
}
.kng-log-sub {
  font-family: system-ui, sans-serif;
  font-size: 11px;
  color: #78716c;
  letter-spacing: 0;
}
.kng-log-body {
  max-height: 190px;
  overflow-y: auto;
  padding: 6px 14px;
  margin: 0;
  list-style: none;
}
.kng-log-line {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 3px 4px;
  border-bottom: 1px dashed #1c1917;
  line-height: 1.3;
  color: #d6d3d1;
  cursor: pointer;
  border-radius: 3px;
}
.kng-log-line:hover { background: #141210; }
.kng-log-t { color: #fde68a; flex-shrink: 0; font-family: var(--vt-font); font-size: 16px; }
.kng-log-i { flex-shrink: 0; }
.kng-log-msg { color: #e7e5e4; }

.kng-chat {
  border-left: 2px solid #292524;
  display: flex;
  flex-direction: column;
  background: #0c0a09;
  font-family: var(--vt-font);
  font-size: calc(17px * var(--olcek));
}
.kng-chat-body {
  flex: 1;
  max-height: 148px;
  min-height: 120px;
  overflow-y: auto;
  padding: 6px 12px;
}
.kng-chat-line {
  display: flex;
  gap: 7px;
  align-items: baseline;
  padding: 2px 0;
  border-bottom: 1px dashed #1c1917;
  line-height: 1.3;
}
.kng-chat-nick { font-weight: 700; flex-shrink: 0; }
.kng-chat-text { color: #e7e5e4; word-break: break-word; }

.kng-chat-form {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  background: #141210;
  border-top: 1px solid #1c1917;
}
.kng-chat-user {
  display: inline-flex;
  align-items: center;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: #0c0a09;
  border: 1px solid #292524;
  border-radius: 4px;
  padding: 5px 8px;
  color: #fde68a;
  font-family: system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
}
.kng-chat-nick-input {
  width: 96px;
  background: #0c0a09;
  border: 1px solid #292524;
  border-radius: 4px;
  padding: 5px 8px;
  color: #fde68a;
  font-family: system-ui, sans-serif;
  font-size: 12px;
}
.kng-chat-input {
  flex: 1;
  background: #0c0a09;
  border: 1px solid #292524;
  border-radius: 4px;
  padding: 5px 9px;
  color: #e7e5e4;
  font-family: system-ui, sans-serif;
  font-size: 12px;
}
.kng-chat-input:disabled {
  opacity: 0.72;
  cursor: pointer;
}
.kng-chat-nick-input:focus, .kng-chat-input:focus { outline: none; border-color: #fde68a; }
.kng-chat-send {
  background: #fde68a;
  color: #0c0a09;
  border: 0;
  border-radius: 4px;
  padding: 6px 11px;
  font-family: var(--pixel-font);
  font-size: 8.5px;
  cursor: pointer;
  white-space: nowrap;
}
.kng-chat-send:disabled { opacity: 0.45; cursor: default; }

#mesaj { position: absolute; left: 12px; right: 12px; top: 52px; z-index: 5; }
#mesaj:empty { display: none; }
#mesaj { padding: 10px 14px; background: #3a1620; border: 1px solid #8a2f45; border-radius: 6px; }

#altbilgi { padding: 8px 4px 0; font-size: 12px; color: #78716c; text-align: center; }
#altbilgi a { color: #a8a29e; }

@media (max-width: 820px) {
  .kng-bottom { grid-template-columns: 1fr; }
  .kng-chat { border-left: 0; border-top: 2px solid #292524; }
  #ust-cubuk.kng-hud { max-width: calc(100% - 20px); font-size: 7.5px; }
  .kng-hud-r { top: auto; bottom: 44px; right: 8px; }
  .kng-hint { display: none; }
}

/* Canlı Yan Panel Önizleme Modu (?mini=1) */
html.is-mini, html.is-mini body {
  height: 100%;
  overflow: hidden;
  background: #090d1a;
}
html.is-mini .kng-shell {
  max-width: none;
  padding: 0;
  margin: 0;
  height: 100%;
}
html.is-mini .kng-wrap {
  border: 0;
  border-radius: 0;
  height: 100%;
  box-shadow: none;
}
html.is-mini .kng-stage {
  height: 100%;
  min-height: 0;
}
html.is-mini .kng-staff,
html.is-mini .kng-bottom,
html.is-mini #altbilgi,
html.is-mini .kng-zoom,
html.is-mini .kng-hint,
html.is-mini .kng-hud-r,
html.is-mini #kart,
html.is-mini #hava-ozet,
html.is-mini #ay-ozet,
html.is-mini #hedef-ozet,
html.is-mini #ust-cubuk .kng-sep:nth-of-type(n+3) {
  display: none !important;
}
html.is-mini #ust-cubuk.kng-hud {
  top: 6px;
  left: 6px;
  max-width: calc(100% - 12px);
  padding: 4px 8px;
  font-size: 7px;
  gap: 5px;
  pointer-events: none;
}
html.is-mini .balon {
  font-size: 13px;
  padding: 3px 7px;
  max-width: 170px;
  pointer-events: none;
}
