/* ---------- Temel ---------- */
:root {
  --bg: #060914;
  --bg-2: #0a1022;
  --panel: #0c1327;
  --panel-2: #111a33;
  --cell: #0f1830;
  --cell-line: #1b2747;
  --line: #1c2844;
  --text: #e8edff;
  --muted: #8592b5;
  --faint: #4a5677;

  --me: #38bdf8;
  --me-deep: #2563eb;
  --me-glow: rgba(56, 189, 248, 0.4);
  --rival: #fb7185;
  --rival-deep: #e11d48;
  --rival-glow: rgba(251, 113, 133, 0.4);
  --ok: #34d399;
  --ok-deep: #059669;
  --warn: #fbbf24;
  --bad: #ef4444;

  --radius: 16px;
  --font: 'Lexend', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 500px at 15% -10%, rgba(56, 189, 248, 0.10), transparent 60%),
    radial-gradient(800px 500px at 110% 110%, rgba(251, 113, 133, 0.10), transparent 60%),
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: auto, auto, 28px 28px, 28px 28px;
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.screen { min-height: 100vh; min-height: 100dvh; }

/* ---------- Menü ---------- */
.menu { display: flex; justify-content: center; padding: 24px 16px 40px; }
.menu-inner { width: 100%; max-width: 560px; display: flex; flex-direction: column; gap: 16px; }

.brand { display: flex; align-items: center; gap: 16px; padding: 8px 4px; }
.brand h1 {
  margin: 0;
  font-size: clamp(34px, 9vw, 48px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  background: linear-gradient(90deg, var(--me), #a78bfa 55%, var(--rival));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand p { margin: 6px 0 0; color: var(--muted); font-size: 15px; }
.logo {
  flex: none;
  display: grid;
  grid-template-columns: repeat(3, 14px);
  gap: 4px;
  padding: 8px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.logo i { width: 14px; height: 14px; border-radius: 4px; background: var(--cell-line); }
.logo i.on { background: linear-gradient(135deg, var(--me), var(--me-deep)); box-shadow: 0 0 10px var(--me-glow); }
.logo i.on:nth-child(even) { background: linear-gradient(135deg, var(--rival), var(--rival-deep)); box-shadow: 0 0 10px var(--rival-glow); }

.panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.panel > .field { margin-top: 18px; }

.label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.name-field input {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* iOS yakınlaştırmasın */
}
.name-field input:focus { outline: none; border-color: var(--me); }
.name-field input::placeholder { color: var(--faint); }

.field.row { display: flex; align-items: center; justify-content: space-between; }
.field.row .label { margin: 0; }
.switch {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 0 14px 0 6px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--bg-2);
  cursor: pointer;
  font-weight: 600;
}
.switch i { position: relative; width: 44px; height: 26px; border-radius: 999px; background: var(--faint); transition: background .2s; }
.switch i::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff;
  transition: transform .2s;
}
.switch[aria-checked="true"] i { background: var(--ok-deep); }
.switch[aria-checked="true"] i::after { transform: translateX(18px); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--panel-2);
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: transform .1s, filter .15s, opacity .15s;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary {
  border: 0;
  color: #031712;
  background: linear-gradient(135deg, var(--ok), #22d3ee);
  box-shadow: 0 8px 28px rgba(52, 211, 153, 0.28);
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn.wide { width: 100%; min-height: 54px; font-size: 17px; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }

.or { display: flex; align-items: center; gap: 10px; margin: 14px 0 10px; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.join-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.join-row input {
  min-width: 0; min-height: 54px; padding: 0 14px;
  border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg-2);
  color: var(--text); font-family: var(--mono); font-size: 24px; font-weight: 700;
  letter-spacing: 0.3em; text-transform: uppercase; text-align: center;
}
.join-row input:focus { outline: none; border-color: var(--me); }
.join-row input::placeholder { color: var(--faint); letter-spacing: 0.2em; }
.join-row .btn { min-height: 54px; padding: 0 22px; }
.hint { margin: 10px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.form-error { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239, 68, 68, 0.4); color: #fca5a5; font-size: 14px; font-weight: 600; }

.rules summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; min-height: 28px; }
.rules summary::-webkit-details-marker { display: none; }
.rules summary::after { content: '+'; font-size: 22px; color: var(--muted); }
.rules[open] summary::after { content: '–'; }
.rules ul { margin: 12px 0 0; padding-left: 20px; color: var(--muted); line-height: 1.55; font-size: 15px; }
.rules li + li { margin-top: 6px; }
.rules b { color: var(--text); }

.records h2 { margin: 0 0 12px; font-size: 17px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.bot-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bot-stats.two { grid-template-columns: repeat(2, 1fr); margin-top: 8px; }
.bot-stat { padding: 10px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); text-align: center; }
.bot-stat span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.bot-stat b { font-family: var(--mono); font-size: 18px; }
.link-btn { border: 0; background: none; color: var(--muted); font-size: 13px; text-decoration: underline; cursor: pointer; padding: 8px 0; min-height: 32px; }

/* ---------- Oyun ekranı ---------- */
.game {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  touch-action: manipulation; /* hızlı dokunuşta çift dokunma yakınlaştırması olmasın */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overflow: hidden;
}

/* Üst bilgi: iki oyuncunun kutu sayısı */
.hud {
  flex: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}
.score { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.score-top { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.score.rival .score-top { justify-content: flex-end; }
.score .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; }
.score.me .nm { color: var(--me); }
.score.rival .nm { color: var(--rival); }
.score .cnt { flex: none; font-family: var(--mono); }
.score .cnt b { font-size: 20px; }
.score .cnt small { color: var(--muted); font-size: 11px; }
.score em { flex: none; font-style: normal; font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--ok); }
.bar { display: block; height: 5px; border-radius: 999px; background: var(--panel-2); overflow: hidden; }
.bar i { display: block; height: 100%; transform-origin: left; transform: scaleX(0); transition: transform .25s ease; border-radius: inherit; }
.score.me .bar i { background: linear-gradient(90deg, var(--me), var(--me-deep)); }
.score.rival .bar { transform: scaleX(-1); }
.score.rival .bar i { background: linear-gradient(90deg, var(--rival), var(--rival-deep)); }
.hud-mid { display: flex; align-items: center; gap: 8px; }
.pill {
  flex: none;
  font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 6px 10px; border-radius: 999px;
  background: rgba(251, 191, 36, 0.10); color: var(--warn); border: 1px solid rgba(251, 191, 36, 0.3);
  white-space: nowrap;
}
.icon-btn {
  flex: none;
  width: 40px; height: 40px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--panel-2);
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; fill: currentColor; }
.net-status {
  flex: none; align-self: center;
  padding: 6px 12px; border-radius: 999px;
  background: rgba(251, 191, 36, 0.12); border: 1px solid rgba(251, 191, 36, 0.4);
  color: var(--warn); font-size: 12px; font-weight: 600; text-align: center;
}

/* Yerleşim (telefon): rakip şeridi üstte, ortada o anki işin, doldururken kendi kâğıdın */
.arena { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.paper-panel, .center {
  min-width: 0; min-height: 0;
  border-radius: var(--radius);
  border: 1.5px solid var(--line);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
}
.paper-panel { display: flex; flex-direction: column; gap: 8px; padding: 10px; }
.paper-panel.me { border-color: color-mix(in srgb, var(--me) 35%, var(--line)); display: none; flex: 1; }
.paper-panel.rival { order: -1; border-color: color-mix(in srgb, var(--rival) 35%, var(--line)); flex-direction: row; align-items: center; justify-content: space-between; padding: 8px 10px 8px 14px; }
.center { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }

.role-fill.phase-running .paper-panel.me,
.role-fill.phase-ending .paper-panel.me { display: flex; }
.role-fill.phase-running .center,
.role-fill.phase-ending .center { flex: none; overflow: visible; padding: 10px 14px; }

.pp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.ttl { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.paper-panel.me .ttl { color: var(--me); }
.paper-panel.rival .ttl { color: var(--rival); }
.pp-note {
  flex: none;
  display: none;
  padding: 4px 8px; border-radius: 8px;
  background: rgba(251, 191, 36, 0.10); border: 1px solid rgba(251, 191, 36, 0.35);
  color: var(--warn); font-size: 11px; font-weight: 600;
}
.role-fill.phase-running .pp-note { display: block; }
.pp-note.warn { animation: shake .4s ease; background: rgba(239, 68, 68, 0.15); border-color: var(--bad); color: #fca5a5; }

/* Kareli kâğıt */
.paper-wrap { position: relative; flex: 1; min-height: 0; container-type: size; display: grid; place-items: center; }
.paper {
  width: min(100cqw, 100cqh, 640px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  gap: clamp(2px, 0.9cqw, 6px);
  padding: clamp(3px, 1cqw, 8px);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  touch-action: none;
}
.pc {
  position: relative;
  min-width: 0; min-height: 0;
  border-radius: 18%;
  background: var(--cell);
  border: 1px solid var(--cell-line);
  display: grid; place-items: center;
}
.pc::after { content: ''; width: 18%; aspect-ratio: 1; border-radius: 50%; background: var(--cell-line); }
.paper-panel.me .pc.f, .paper-panel.me .pc.n { background: linear-gradient(145deg, var(--me), var(--me-deep)); border-color: color-mix(in srgb, var(--me) 65%, white); }
.paper-panel.rival .pc.f, .paper-panel.rival .pc.n { background: linear-gradient(145deg, var(--rival), var(--rival-deep)); border-color: color-mix(in srgb, var(--rival) 65%, white); }
.pc.f::after, .pc.n::after {
  width: 36%; height: 18%; aspect-ratio: auto; border-radius: 0; background: none;
  border-left: max(1.5px, 0.5cqw) solid rgba(255, 255, 255, 0.9);
  border-bottom: max(1.5px, 0.5cqw) solid rgba(255, 255, 255, 0.9);
  transform: translateY(-15%) rotate(-45deg);
}
.pc.n { box-shadow: 0 0 12px -2px var(--me-glow); }
.paper-panel.rival .pc.n { box-shadow: 0 0 10px -2px var(--rival-glow); }
.pc.pop { animation: pop .26s ease-out; }
.game.live.role-fill .paper-panel.me .pc:not(.f):not(.n) { cursor: pointer; }
@media (hover: hover) {
  .game.live.role-fill .paper-panel.me .pc:not(.f):not(.n):hover { border-color: var(--me); }
}
.role-fill.phase-running:not(.live) .paper-panel.me .paper,
.phase-ending .paper-panel.me .paper { filter: saturate(0.6) brightness(0.75); }

/* Rakibin kâğıdı telefonda küçük, canlı */
.paper-panel.rival .paper-wrap { flex: none; container-type: normal; }
.paper-panel.rival .paper { width: 74px; gap: 1px; padding: 2px; border-radius: 6px; }
.paper-panel.rival .pc { border-radius: 2px; border: 0; }
.paper-panel.rival .pc::after { display: none; }

/* Orta panel parçaları */
.kicker { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.center h2 { margin: 2px 0 0; font-size: 19px; font-weight: 800; line-height: 1.2; }
.center h2 em { font-style: normal; text-transform: uppercase; }
.role-fill-txt { color: var(--me); }
.role-find-txt { color: var(--warn); }
.center-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.badges { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 8px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-2);
  font-size: 12px; font-weight: 600; white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis;
}
.badge b { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 2px 6px; border-radius: 6px; background: var(--panel-2); }
.badge.on { border-color: rgba(52, 211, 153, 0.5); }
.badge.on b { color: #031712; background: var(--ok); }

.turn-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  padding: 10px 12px; border-radius: 12px;
  border: 1px solid rgba(52, 211, 153, 0.35); background: rgba(52, 211, 153, 0.08);
  font-size: 14px;
}
.turn-banner b { color: var(--ok); }
.turn-banner span:last-child { margin-left: auto; color: var(--text); font-weight: 600; font-family: var(--mono); font-size: 13px; }
.ok-ico { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--ok); color: #031712; font-size: 12px; font-weight: 800; }
.rec-note { padding: 8px 12px; border-radius: 10px; border: 1px solid rgba(251, 191, 36, 0.4); background: rgba(251, 191, 36, 0.08); color: var(--warn); font-size: 13px; font-weight: 600; }

.pick-row { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }
.picked {
  min-width: 44px; padding: 4px 10px; border-radius: 10px; text-align: center;
  font-family: var(--mono); font-size: 20px; color: #1a1300; background: var(--warn);
}
.pick-row .btn { margin-left: auto; }
.sub { display: flex; justify-content: space-between; gap: 10px; margin: 0; font-size: 12px; color: var(--muted); }
.sub b { color: var(--warn); font-family: var(--mono); white-space: nowrap; }

.numbers { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.num {
  min-width: 0;
  aspect-ratio: 1.15;
  max-height: 46px;
  border-radius: 9px;
  border: 1.5px solid var(--cell-line);
  background: linear-gradient(180deg, #121c38, var(--cell));
  font-family: var(--mono); font-weight: 700; font-size: 15px;
  cursor: pointer;
  padding: 0;
  touch-action: manipulation;
}
.num:disabled { cursor: default; }
.num.used { color: var(--faint); text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: var(--rival); background: transparent; border-style: dashed; }
.num.sel { background: var(--warn); color: #1a1300; border-color: #fde68a; box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.3); }
@media (hover: hover) { .num:not(:disabled):not(.sel):hover { border-color: var(--warn); } }
.num.hit { background: linear-gradient(145deg, #6ee7b7, var(--ok-deep)); color: #031712; border-color: #a7f3d0; animation: pop .3s ease-out; }
.num.miss { animation: shake .45s ease; background: linear-gradient(145deg, #f87171, #b91c1c); border-color: #fecaca; color: #fff; }

.btn.go { width: 100%; min-height: 56px; font-size: 17px; letter-spacing: 0.02em; flex: none; }
.deadline { margin: -4px 0 0; text-align: center; font-size: 12px; color: var(--muted); min-height: 1em; }
.explain { margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.55; font-size: 14px; }
.explain b { color: var(--text); }
.explain li + li { margin-top: 4px; }

.run-card { display: flex; flex-direction: column; gap: 4px; position: relative; }
.run-line { margin: 0; font-size: 15px; line-height: 1.45; }
.tgt { font-family: var(--mono); color: var(--warn); font-size: 20px; }
.opp-err { margin: 0; font-size: 12px; color: var(--bad); min-height: 1em; }
.sub-c { margin: 0; color: var(--muted); font-size: 13px; }
.countdown {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-weight: 700; font-size: 48px; color: var(--warn);
  text-shadow: 0 0 24px rgba(251, 191, 36, 0.5);
}
.countdown.pop { animation: count-pop .3s cubic-bezier(.2, 1.4, .4, 1); }

.find-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.target {
  position: relative;
  flex: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 110px; padding: 8px 14px;
  border-radius: 14px;
  border: 1.5px solid color-mix(in srgb, var(--warn) 50%, var(--line));
  background: radial-gradient(80px 40px at 50% 50%, rgba(251, 191, 36, 0.14), transparent 70%), var(--bg-2);
}
.target span { font-size: 11px; font-weight: 800; letter-spacing: 0.12em; color: var(--warn); }
.target b { font-family: var(--mono); font-size: 46px; line-height: 1; text-shadow: 0 0 22px rgba(251, 191, 36, 0.45); }
.target b.pop { animation: count-pop .3s cubic-bezier(.2, 1.4, .4, 1); }
.target .countdown { position: absolute; inset: 0; transform: none; display: grid; place-items: center; background: var(--bg-2); border-radius: inherit; font-size: 46px; }
.numbers-wrap { position: relative; }
.numbers.shuffled .num { font-size: 17px; aspect-ratio: 0.9; max-height: 56px; }
.game:not(.live) .numbers.shuffled .num:not(.used) { color: transparent; }
.numbers-wrap.locked .numbers { filter: saturate(0.4) brightness(0.55); }
.numbers-wrap.shake .numbers { animation: shake .4s ease; }
.lock {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: none; flex-direction: column; align-items: center; gap: 8px;
  padding: 12px 18px; border-radius: 14px;
  background: rgba(127, 29, 29, 0.92); border: 1.5px solid #fca5a5;
  color: #fff; font-weight: 800; letter-spacing: 0.08em; font-size: 15px;
  pointer-events: none;
}
.lock i { display: block; width: 90px; height: 5px; border-radius: 999px; background: #fecaca; transform-origin: left; }
.numbers-wrap.locked .lock { display: flex; }
.numbers-wrap.locked .lock i { animation: drain var(--lock-ms, 1000ms) linear forwards; }

@keyframes pop { 0% { transform: scale(0.75); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes count-pop { from { transform: scale(0.5); opacity: 0.2; } to { transform: scale(1); opacity: 1; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* Geniş ekran: kendi kâğıdın | orta panel | rakibin kâğıdı */
@media (min-width: 960px) and (min-aspect-ratio: 5/4) {
  .game { padding: 16px 24px; gap: 14px; max-width: 1500px; margin: 0 auto; }
  .hud { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
  .score .cnt b { font-size: 24px; }
  .arena { display: grid; grid-template-columns: minmax(0, 1fr) 410px minmax(0, 1fr); gap: 16px; }
  .paper-panel.me { display: flex; order: 0; }
  .paper-panel.rival { order: 2; flex-direction: column; align-items: stretch; padding: 12px; }
  .paper-panel.rival .paper-wrap { flex: 1; container-type: size; }
  .paper-panel.rival .paper { width: min(100cqw, 100cqh, 640px); gap: clamp(2px, 0.9cqw, 6px); padding: clamp(3px, 1cqw, 8px); border-radius: 12px; }
  .paper-panel.rival .pc { border-radius: 18%; border: 1px solid var(--cell-line); }
  .paper-panel.rival .pc::after { display: grid; }
  .center { order: 1; }
  .role-fill.phase-running .center, .role-fill.phase-ending .center { flex: 1; padding: 14px; }
  .role-fill.phase-running .run-card { margin-top: auto; margin-bottom: auto; }
  .run-card .countdown { position: static; transform: none; font-size: 72px; text-align: center; }
}

/* Telefonda isimler sayının üstünde kendi satırında; kâğıt başlığı uyarıyla alt alta */
@media (max-width: 559px) {
  .score-top { flex-wrap: wrap; row-gap: 0; }
  .score .nm { flex-basis: 100%; font-size: 11px; }
  .score.rival .nm { order: -1; text-align: right; }
  .pp-head { flex-wrap: wrap; row-gap: 6px; }
}

/* Kısa telefon ekranı: sayı tahtası sıkışsın */
@media (max-height: 700px) and (max-width: 959px) {
  .numbers { gap: 4px; }
  .num { aspect-ratio: 1.35; }
  .center { gap: 10px; padding: 12px; }
}

/* ---------- Katman (lobi, çıkış, oyun sonu) ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(3, 6, 15, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  overflow-y: auto;
}
.sheet {
  width: 100%; max-width: 480px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 22px;
  border-radius: 20px;
  background: linear-gradient(180deg, #121b36, var(--panel));
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  animation: sheet-in .25s cubic-bezier(.2, 1.2, .4, 1);
}
@keyframes sheet-in { from { transform: translateY(14px) scale(0.97); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet h2 { margin: 4px 0 0; font-size: clamp(22px, 6vw, 28px); font-weight: 800; line-height: 1.15; }
.sheet .reason { margin: 8px 0 0; color: var(--muted); font-size: 15px; line-height: 1.45; }
.sheet h2.win-0 { color: var(--me); }
.sheet h2.win-1 { color: var(--rival); }
.sheet h2.draw { color: var(--warn); }

.room-code {
  margin: 18px 0 14px;
  padding: 14px 14px 14px calc(14px + 0.25em);
  border-radius: 16px;
  border: 1.5px dashed color-mix(in srgb, var(--warn) 55%, var(--line));
  background: rgba(251, 191, 36, 0.06);
  font-family: var(--mono); font-weight: 700;
  font-size: clamp(40px, 13vw, 60px); letter-spacing: 0.25em;
  text-align: center; color: var(--warn);
  user-select: all; -webkit-user-select: all;
}
.share-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.share-row input {
  min-width: 0; min-height: 46px; padding: 0 12px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2);
  color: var(--muted); font: inherit; font-size: 14px;
}
.waiting-line { display: flex; align-items: center; gap: 10px; margin: 16px 0 0; color: var(--muted); font-weight: 600; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--me); animation: dot 1.1s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }

.match-score {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-top: 16px; padding: 12px; border-radius: 14px;
  background: var(--bg-2); border: 1px solid var(--line);
  font-weight: 600;
}
.match-score b { font-family: var(--mono); font-size: 26px; }
.match-score .s0 b { color: var(--me); }
.match-score .s1 b { color: var(--rival); }
.match-score .s0, .match-score .s1 { display: flex; align-items: center; gap: 10px; min-width: 0; }
.match-score .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }
.match-score .dash { color: var(--faint); }
.ready-note { margin: 14px 0 0; text-align: center; color: var(--ok); font-weight: 600; font-size: 14px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 20px; }
.sheet-actions .btn { flex: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
