/* GHOUL — faz arayüzün rengini belirler: gece çivit + fener, gündüz kemik + is. */

:root {
  --ink: #161b33;        /* gece gökyüzü */
  --mist: #2b3354;       /* gece yüzeyleri */
  --lantern: #e9a441;    /* fener ışığı */
  --blood: #a3322a;      /* ölüm, ghoul */
  --bone: #e4dccb;       /* gündüz zemin */
  --soot: #2a2622;       /* gündüz mürekkep */
  --moss: #5b6b48;       /* köy */

  --bg: var(--ink);
  --surface: var(--mist);
  --text: #e6e1d6;
  --muted: #9aa0b8;
  --accent: var(--lantern);
  --line: rgba(230, 225, 214, .14);

  --display: "Grenze Gotisch", "UnifrakturMaguntia", Georgia, serif;
  --body: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;

  --step--1: .875rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.625rem;
  --step-3: 2.25rem;
  --step-5: clamp(4rem, 14vw, 8.5rem);

  color-scheme: dark;
}

/* Gündüz ve oylama: köy meydanı, kemik rengi */
body[data-phase="day"], body[data-phase="vote"], body[data-phase="lobby"], body[data-phase="over"] {
  --bg: var(--bone);
  --surface: #d8cfbb;
  --text: var(--soot);
  --muted: #6d655a;
  --accent: var(--blood);
  --line: rgba(42, 38, 34, .18);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--step-0)/1.5 var(--body);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  transition: background-color 1.6s ease, color 1.6s ease;
}
[hidden] { display: none !important; }

h1, h2, h3 { font-family: var(--display); font-weight: 500; margin: 0; line-height: 1.05; }
p { margin: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------------ butonlar */
.btn {
  font: 500 var(--step-0)/1 var(--body);
  color: var(--text);
  background: transparent;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  padding: .8em 1.2em;
  cursor: pointer;
  min-height: 44px;
}
.btn:hover:not(:disabled) { background: var(--line); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); font-weight: 700; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.btn.small { padding: .55em .9em; min-height: 38px; font-size: var(--step--1); }
.btn.danger { color: var(--blood); }

input, select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 3px;
  padding: .7em .8em;
  min-height: 44px;
  width: 100%;
}
input:focus { border-color: var(--accent); outline: none; }

/* ------------------------------------------------------------------ giriş */
.home {
  max-width: 34rem;
  margin: 0 auto;
  padding: 12vh 1.5rem 4rem;
}
.wordmark {
  font-size: var(--step-5);
  color: var(--lantern);
  letter-spacing: -.01em;
  line-height: .85;
  margin-left: -.04em;
  text-shadow: 0 0 48px rgba(233, 164, 65, .35);
}
.lede { font-size: var(--step-1); margin: 1.25rem 0 2.5rem; max-width: 28em; color: var(--text); }
.home-forms { display: grid; gap: 1rem; }
.field { display: grid; gap: .35rem; }
.field span { font-size: var(--step--1); color: var(--muted); }
.or { color: var(--muted); font-size: var(--step--1); margin-top: .75rem; }
.join-row { display: grid; grid-template-columns: 1fr auto; gap: .5rem; }
#codeInput { text-transform: uppercase; letter-spacing: .2em; font-weight: 700; }
.form-error { color: #e07b72; min-height: 1.5em; font-size: var(--step--1); }
.howto { margin-top: 3rem; border-top: 1px solid var(--line); padding-top: 1rem; color: var(--muted); }
.howto summary { cursor: pointer; color: var(--text); font-weight: 500; }
.howto p { margin-top: .75rem; max-width: 34em; }

/* ------------------------------------------------------------------ fitil (zaman) */
.fuse { position: fixed; inset: 0 0 auto 0; height: 3px; background: var(--line); z-index: 10; }
.fuse-burn { height: 100%; background: var(--accent); transform-origin: left; }

/* ------------------------------------------------------------------ masa */
.table { max-width: 76rem; margin: 0 auto; padding: 1.5rem 1rem 2rem; }
.topbar { display: flex; align-items: end; justify-content: space-between; gap: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.phase h2 { font-size: var(--step-3); }
.phase p { color: var(--muted); margin-top: .25rem; }
.clock { font: 700 var(--step-2)/1 var(--body); font-variant-numeric: tabular-nums; color: var(--accent); }

.table-grid { display: grid; gap: 1.5rem; margin-top: 1.25rem; grid-template-columns: minmax(0, 1fr) 22rem; align-items: start; }
@media (max-width: 860px) { .table-grid { grid-template-columns: 1fr; } }

.board { display: grid; gap: 1.25rem; min-width: 0; }

/* Duyuru: şafak / idam haberi */
.announce {
  font: 500 var(--step-1)/1.35 var(--body);
  border-left: 4px solid var(--blood);
  padding: .6rem 0 .6rem 1rem;
}
.announce strong { font-weight: 700; }
.announce .vote-detail { font-size: .9rem; color: var(--muted); margin-top: .3rem; }
.btn.kick { margin-top: .3rem; width: 100%; }

/* Lobi */
.invite { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; }
.invite-label { display: block; color: var(--muted); font-size: var(--step--1); }
.code { font: 700 var(--step-3)/1 var(--body); letter-spacing: .18em; }
.settings { display: grid; gap: .9rem; padding: 1rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.settings h3 { font-family: var(--body); font-weight: 700; font-size: var(--step-0); }
.check { display: flex; gap: .7rem; align-items: start; cursor: pointer; }
.check input { width: 1.2rem; height: 1.2rem; min-height: 0; margin-top: .15rem; accent-color: var(--blood); flex: none; }
.check small { display: block; color: var(--muted); }
.durations { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
.durations label { display: grid; gap: .25rem; font-size: var(--step--1); color: var(--muted); }
.readonly .check, .readonly select { pointer-events: none; }

/* Rol kartı */
.role-card {
  display: grid; gap: .4rem;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border-radius: 4px;
  border-top: 4px solid var(--moss);
}
.role-card.ghoul { border-top-color: var(--blood); }
.role-card .who { color: var(--muted); font-size: var(--step--1); }
.role-card h3 { font-size: var(--step-2); }
.role-card .team-list, .role-card .findings { font-size: var(--step--1); }
.findings li { margin-top: .15rem; }
.findings .yes { color: #e07b72; font-weight: 700; }

.prompt { font-size: var(--step-1); min-height: 1.5em; }

/* Köy: her oyuncu bir kapı */
.village {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: .6rem;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
}
.door {
  position: relative;
  display: grid; gap: .15rem; align-content: end;
  min-height: 5.5rem;
  padding: .7rem .75rem;
  text-align: left;
  font: inherit; color: var(--text);
  background: var(--surface);
  border: 1.5px solid transparent;
  border-radius: 2.5rem 2.5rem 3px 3px;   /* kemerli kapı */
  width: 100%;
}
button.door { cursor: pointer; }
button.door:hover { border-color: var(--accent); }
.door.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.door .name { font-weight: 700; overflow-wrap: anywhere; line-height: 1.2; }
.door .meta { font-size: .8rem; color: var(--muted); min-height: 1.2em; }
.door.me .name::after { content: " (sen)"; font-weight: 400; color: var(--muted); }
.door.offline { opacity: .6; }
.door.dead { background: transparent; border: 1.5px dashed var(--line); }
.door.dead .name { text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: var(--blood); }
.door.ally { border-color: var(--blood); }
.door .tags {
  position: absolute; top: .55rem; right: .6rem; left: .6rem;
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .25rem;
}
.door .tag {
  font-size: .72rem; font-weight: 700;
  padding: .1rem .4rem; border-radius: 2px;
  background: var(--blood); color: #f4ede0;
}
.door .tag.soft { background: var(--line); color: var(--text); }

.actions { display: flex; flex-wrap: wrap; gap: .6rem; }

/* ------------------------------------------------------------------ sohbet */
.chat {
  display: grid; grid-template-rows: minmax(0, 1fr) auto;
  height: min(70vh, 38rem);
  border: 1.5px solid var(--line); border-radius: 4px;
  position: sticky; top: 1rem;
  background: color-mix(in srgb, var(--surface) 45%, transparent);
}
@media (max-width: 860px) { .chat { position: static; height: 55vh; } }
.chat-log { list-style: none; margin: 0; padding: .8rem; overflow-y: auto; display: grid; gap: .45rem; align-content: start; overscroll-behavior: contain; }
.chat-log li { font-size: .95rem; overflow-wrap: anywhere; }
.chat-log .from { font-weight: 700; margin-right: .35rem; }
.chat-log .ghoul { color: #e07b72; }
body[data-phase="day"] .chat-log .ghoul, body[data-phase="vote"] .chat-log .ghoul,
body[data-phase="over"] .chat-log .ghoul { color: var(--blood); }
.chat-log .dead { color: var(--muted); font-style: italic; }
.chat-log .system { color: var(--muted); font-size: var(--step--1); text-align: center; }
.chat-log .chan { font-size: .72rem; font-weight: 700; margin-right: .35rem; opacity: .8; }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: .4rem; padding: .5rem; border-top: 1px solid var(--line); }
.chat-form input:disabled { opacity: .5; }

/* ------------------------------------------------------------------ bildirim */
.toast {
  position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--soot); color: var(--bone);
  padding: .7rem 1rem; border-radius: 3px;
  max-width: calc(100vw - 2rem); z-index: 20;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
}

/* Faz başlığı değişince tek seferlik belirme */
.phase h2.enter { animation: rise 1.2s ease both; }
@keyframes rise { from { opacity: 0; letter-spacing: .12em; } to { opacity: 1; letter-spacing: 0; } }

@media (prefers-reduced-motion: reduce) {
  body { transition: none; }
  .phase h2.enter { animation: none; }
}
