:root {
  --bg: #0b0f1e;
  --bg2: #141a33;
  --card: #1b2342;
  --line: #2b3563;
  --text: #e8ecff;
  --muted: #8f9bd0;
  --accent: #46e0ff;
  --accent2: #ff4fd8;
  --ok: #4dff9a;
  --warn: #ffd34d;
  --bad: #ff5468;
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #1d2758 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.btn {
  border: 0; border-radius: var(--radius); padding: 16px 24px;
  background: linear-gradient(135deg, var(--accent), #2f8bff); color: #041022;
  font-weight: 800; font-size: 1.1rem; letter-spacing: .02em;
  box-shadow: 0 6px 24px #46e0ff44;
}
.btn.secondary { background: var(--card); color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .4; }

input.field {
  width: 100%; padding: 16px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font-size: 1.2rem; outline: none;
}
input.field:focus { border-color: var(--accent); }
.code-input { text-transform: uppercase; letter-spacing: .4em; text-align: center; font-weight: 800; }

/* ---------- Giriş ---------- */
.landing { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; text-align: center; }
.landing h1 { font-size: clamp(2.4rem, 8vw, 4.5rem); margin: 0 0 8px; letter-spacing: -.02em; }
.landing h1 span { background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.landing p { max-width: 480px; margin: 0 auto 32px; line-height: 1.5; }
.landing .actions { display: grid; gap: 12px; width: min(360px, 100%); margin: 0 auto; }
.landing a.btn { text-decoration: none; display: block; }

/* ---------- Ana ekran ---------- */
.host { min-height: 100%; padding: 32px; display: flex; flex-direction: column; gap: 24px; }
.host header { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.host header h1 { margin: 0; font-size: 1.6rem; }
.room-code { font-size: clamp(3rem, 9vw, 7rem); font-weight: 900; letter-spacing: .15em; color: var(--accent); line-height: 1; }
.join-url { font-size: 1.3rem; word-break: break-all; }
.lobby { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: start; }
.panel-box { background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 28px; }
.players { display: flex; flex-wrap: wrap; gap: 10px; min-height: 48px; }
.chip { background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; font-weight: 700; }
.chip.off { opacity: .45; text-decoration: line-through; }
.chip b { color: var(--ok); margin-left: 6px; }

.hud { display: grid; grid-template-columns: auto 1fr 1fr; gap: 24px; align-items: center; }
.level-badge { font-size: 2rem; font-weight: 900; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 12px 24px; white-space: nowrap; }
.meter label { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 8px; }
.bar { height: 22px; background: var(--bg2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.bar > div { height: 100%; width: 0; border-radius: 999px; transition: width .3s ease, background .3s; }
.bar.hull > div { background: var(--ok); }
.bar.progress > div { background: linear-gradient(90deg, var(--accent), var(--accent2)); }

.stage { flex: 1; display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; min-height: 300px; }
.space { position: relative; overflow: hidden; border-radius: 24px; background: #050817; border: 1px solid var(--line); display: grid; place-items: center; }
.stars { position: absolute; inset: 0; background-image:
  radial-gradient(2px 2px at 20% 30%, #fff8, transparent), radial-gradient(1px 1px at 70% 60%, #fff9, transparent),
  radial-gradient(2px 2px at 40% 80%, #fff6, transparent), radial-gradient(1px 1px at 90% 20%, #fffa, transparent),
  radial-gradient(1px 1px at 10% 70%, #fff8, transparent), radial-gradient(2px 2px at 60% 10%, #fff7, transparent);
  background-size: 300px 300px; animation: drift 6s linear infinite; }
@keyframes drift { from { background-position: 0 0; } to { background-position: -300px 0; } }
.ship { font-size: clamp(5rem, 14vw, 10rem); filter: drop-shadow(0 0 30px #46e0ff66); transform: rotate(45deg); transition: filter .3s; }
.ship.hit { animation: shake .45s; filter: drop-shadow(0 0 40px #ff5468); }
@keyframes shake {
  0%,100% { transform: rotate(45deg) translate(0,0); }
  20% { transform: rotate(40deg) translate(-12px, 6px); }
  40% { transform: rotate(50deg) translate(10px, -8px); }
  60% { transform: rotate(42deg) translate(-8px, -4px); }
  80% { transform: rotate(48deg) translate(6px, 4px); }
}
.feed { display: flex; flex-direction: column; gap: 10px; }
.feed .ev { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; font-size: 1.15rem; animation: pop .25s ease; }
.feed .ev.miss { border-color: var(--bad); }
.feed .ev.ok { border-color: #2f7f5a; }
.feed .ev.level { border-color: var(--accent); }
@keyframes pop { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }

.overlay { position: fixed; inset: 0; background: #050817dd; display: grid; place-items: center; text-align: center; padding: 24px; z-index: 10; }
.overlay h2 { font-size: clamp(2.5rem, 8vw, 5rem); margin: 0 0 12px; }
.overlay .stats { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 24px 0; }
.overlay .actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- Telefon ---------- */
.phone { min-height: 100%; max-width: 560px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.phone .center { flex: 1; display: grid; place-items: center; text-align: center; }
.phone form { display: grid; gap: 12px; width: 100%; }
.phone .error { color: var(--bad); min-height: 1.4em; font-weight: 700; }
.topline { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: .95rem; color: var(--muted); }
.mini-hull { width: 90px; height: 10px; }

.order { background: linear-gradient(160deg, #26305e, var(--card)); border: 2px solid var(--accent); border-radius: 20px; padding: 18px; min-height: 120px; display: flex; flex-direction: column; justify-content: space-between; gap: 12px; }
.order .text { font-size: 1.35rem; font-weight: 800; line-height: 1.25; }
.order.idle { border-color: var(--line); }
.order.idle .text { color: var(--muted); font-weight: 600; }
.order.urgent { border-color: var(--bad); animation: pulse .5s infinite alternate; }
@keyframes pulse { to { box-shadow: 0 0 24px #ff546888; } }
.timer { height: 8px; background: var(--bg2); border-radius: 999px; overflow: hidden; }
.timer > div { height: 100%; background: var(--accent); width: 100%; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; flex: 1; }
.ctrl { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 12px; display: flex; flex-direction: column; gap: 10px; justify-content: space-between; min-height: 150px; }
.ctrl .label { font-weight: 800; font-size: .95rem; line-height: 1.2; text-align: center; min-height: 2.4em; }
.ctrl.flash { animation: flash .35s; }
@keyframes flash { 50% { background: #46e0ff33; } }

.push { flex: 1; border-radius: 50%; aspect-ratio: 1; max-height: 96px; margin: 0 auto; border: 0; background: radial-gradient(circle at 35% 30%, #ff8de8, var(--accent2) 60%, #8a1f78); box-shadow: 0 6px 0 #6b155d, 0 10px 20px #0008; }
.push:active { transform: translateY(5px); box-shadow: 0 1px 0 #6b155d; }

.switch { flex: 1; border: 2px solid var(--line); border-radius: 14px; background: var(--bg2); font-weight: 900; font-size: 1.2rem; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 64px; }
.switch.on { background: #12452f; border-color: var(--ok); color: var(--ok); }

.slider { display: flex; flex-direction: column; gap: 6px; }
.slider .value { text-align: center; font-size: 1.8rem; font-weight: 900; color: var(--warn); }
.slider input { width: 100%; height: 36px; accent-color: var(--warn); }
.slider .ticks { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); padding: 0 4px; }

.dial { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.dial button { border: 1px solid var(--line); background: var(--bg2); border-radius: 10px; padding: 10px 4px; font-weight: 800; font-size: .8rem; }
.dial button.sel { background: var(--accent); color: #041022; border-color: var(--accent); }

@media (max-width: 900px) {
  .host { padding: 16px; }
  .lobby, .stage { grid-template-columns: 1fr; }
  .hud { grid-template-columns: 1fr; }
}

/* ---------- Faz 2 ---------- */
.phone-page { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.grid-wrap { position: relative; flex: 1; display: flex; }
.grid-wrap .grid { flex: 1; }
.grid > .ctrl:last-child:nth-child(odd) { grid-column: span 2; }

.holdbtn { position: relative; overflow: hidden; flex: 1; min-height: 64px; border-radius: 14px; border: 2px solid #3f6cff; background: #14204d; font-weight: 900; touch-action: none; }
.holdbtn .fill { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #3f6cff, var(--accent)); }
.holdbtn .txt { position: relative; }
.mashbtn { flex: 1; min-height: 64px; border-radius: 14px; border: 0; font-size: 1.5rem; font-weight: 900; color: #2a1600; background: linear-gradient(160deg, #ffd34d, #ff8a3d); box-shadow: 0 5px 0 #a3501c; touch-action: manipulation; }
.mashbtn:active { transform: translateY(4px); box-shadow: 0 1px 0 #a3501c; }

.rule-chip { background: #2a1f4d; border: 1px solid #7a5cff; border-radius: 12px; padding: 8px 12px; font-size: .85rem; line-height: 1.3; }
.rule-chip span { color: var(--muted); }
.mirror { transform: scaleX(-1); }

.blackout { position: absolute; inset: 0; background: #000; border-radius: 18px; display: grid; place-items: center; text-align: center; font-size: 1.6rem; font-weight: 800; color: #555; z-index: 5; }
.blackout small { font-size: .9rem; font-weight: 600; }

.meteor { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; text-align: center; background: radial-gradient(circle at 50% 40%, #5a1020, #1a0308 75%); animation: alarm .6s infinite alternate; }
.meteor-title { font-size: 2.6rem; font-weight: 900; }
.meteor p { margin: 0; font-size: 1.2rem; }
.shield { width: min(80vw, 320px); aspect-ratio: 1; border-radius: 50%; border: 0; font-size: 1.6rem; font-weight: 900; color: #041022; background: radial-gradient(circle at 35% 30%, #b8f6ff, var(--accent) 60%, #1a6a80); box-shadow: 0 8px 0 #134d5d, 0 0 40px #46e0ff88; }
.shield:disabled { opacity: 1; font-size: 1.1rem; background: #12452f; color: var(--ok); box-shadow: none; }
@keyframes alarm { to { background-color: #300; filter: brightness(1.15); } }

.glitching .grid, .glitching .order { animation: glitch .9s steps(2); }
@keyframes glitch {
  0% { transform: translate(0); filter: hue-rotate(0); }
  20% { transform: translate(-6px, 3px) skewX(6deg); filter: hue-rotate(90deg); }
  40% { transform: translate(5px, -4px) skewX(-8deg); }
  60% { transform: translate(-3px, 2px); filter: hue-rotate(200deg) saturate(3); }
  80% { transform: translate(4px, 0) skewX(4deg); }
  100% { transform: translate(0); filter: none; }
}

.news { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 8px; text-align: left; }
.news li { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-weight: 700; }
.rule-card { margin-top: 12px; background: #2a1f4d; border: 1px solid #7a5cff; border-radius: 14px; padding: 12px 16px; display: grid; gap: 4px; }

/* Ana ekran */
.rule-badge { background: #2a1f4d; border: 1px solid #7a5cff; border-radius: 16px; padding: 10px 16px; font-size: 1.1rem; }
.rule-badge span { color: var(--muted); margin-left: 8px; }
.alert { position: absolute; top: 16px; left: 16px; right: 16px; z-index: 2; border-radius: 16px; padding: 14px 18px; font-size: 1.4rem; font-weight: 900; text-align: center; }
.alert.meteor-alert { background: #5a1020; border: 2px solid var(--bad); animation: pulse .5s infinite alternate; }
.alert.blackout-alert { background: #111; border: 2px solid #444; color: #aaa; }
.space.dark { filter: brightness(.35); }
.space.glitch { animation: glitch .9s steps(2); }
.feed .ev.rule { border-color: #7a5cff; }
.feed .ev.event { border-color: var(--warn); }
.overlay .news { max-width: 520px; margin: 20px auto 0; font-size: 1.2rem; }

/* ---------- Faz 3: sabotajcı ---------- */
.role-btn { align-self: flex-start; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 14px; font-weight: 800; font-size: .9rem; }
.role-drawer { background: #1a1230; border: 1px solid #7a5cff; border-radius: 14px; padding: 12px 14px; display: grid; gap: 10px; }
.role-drawer .sab { color: var(--bad); font-size: 1.15rem; }
.sabo-list { display: grid; gap: 8px; }
.sabo-list:empty { display: none; }
.sabo { display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--bad); background: #3a0f1a; border-radius: 12px; padding: 12px 14px; font-weight: 800; }
.sabo:disabled { opacity: .5; }
.sabo .cd { font-size: .8rem; color: var(--muted); font-weight: 600; }

.vote-list { display: grid; gap: 10px; }
.vote-btn { border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 18px; font-size: 1.2rem; font-weight: 800; text-align: left; }
.vote-btn.skip { color: var(--muted); }
.vote-btn.sel { border-color: var(--accent); background: #12324a; color: var(--text); }
.vote-btn:disabled:not(.sel) { opacity: .45; }

.chip.ejected { opacity: .5; }
.chip.voted { border-color: var(--ok); }
.chip.sab { border-color: var(--bad); }
.chip i { font-style: normal; color: var(--bad); margin-left: 6px; }
.lobby-opt { display: flex; gap: 10px; align-items: center; margin: 4px 0 16px; font-weight: 700; }
.lobby-opt input { width: 22px; height: 22px; accent-color: var(--accent2); }

/* ---------- Ana ekransız akış ---------- */
.or { text-align: center; font-size: .9rem; }
.lobby-phone { display: flex; flex-direction: column; gap: 12px; padding-top: 12px; text-align: center; }
.lobby-phone .players { justify-content: center; }
.lobby-phone .room-code { font-size: 4.5rem; }
.share-url { font-size: .8rem; word-break: break-all; }
.hud-phone { display: grid; gap: 6px; }
.hud-phone .topline { gap: 8px; }
.meters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.meter-sm { display: grid; grid-template-columns: auto 1fr; gap: 6px; align-items: center; font-size: .85rem; }
.meter-sm .bar { height: 10px; }
.ticker { min-height: 1.6em; font-size: .9rem; font-weight: 700; padding: 4px 10px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticker:empty { visibility: hidden; }
.ticker.miss { border-color: var(--bad); }
.ticker.ok { border-color: #2f7f5a; }
.ticker.event { border-color: var(--warn); }
.ticker.vote, .ticker.rule { border-color: #7a5cff; }
.players.stats { justify-content: center; margin-top: 16px; }
.wait-actions { display: grid; gap: 10px; margin-top: 20px; }

/* ---------- Faz 4: salla ---------- */
.shakebtn { flex: 1; min-height: 64px; border-radius: 14px; border: 2px dashed #b06cff; background: #241640; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-weight: 800; touch-action: manipulation; position: relative; }
.shake-icon { font-size: 1.8rem; }
.shake-hint { font-size: .75rem; color: var(--muted); font-weight: 600; }
.shake-count { position: absolute; top: 6px; right: 10px; color: #d6b4ff; font-weight: 900; }
.t-shake.flash .shake-icon { animation: wobble .35s; }
@keyframes wobble { 25% { transform: rotate(-20deg); } 75% { transform: rotate(20deg); } }

/* ---------- Faz 5: cila ---------- */
.icon-btn { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: .9rem; }
.howto-link { color: var(--accent); font-weight: 700; text-decoration: none; text-align: center; padding: 6px; }
.lobby-links { display: flex; justify-content: center; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.qr-box { margin: 4px auto 0; display: grid; justify-items: center; gap: 6px; }
.qr { width: 180px; height: 180px; background: #fff; border-radius: 12px; padding: 6px; }
.qr-box figcaption { font-size: .8rem; }

/* Kaçırılan talimatta ekran sarsıntısı */
main.phone.hit { animation: hit .4s; }
@keyframes hit {
  0%, 100% { transform: none; }
  20% { transform: translate(-8px, 2px); }
  40% { transform: translate(7px, -3px); }
  60% { transform: translate(-5px, 1px); }
  80% { transform: translate(3px, 0); }
}
main.phone.hit .ticker { background: #3a0f1a; }

/* Yeni talimat kartı */
.order.pop { animation: pop-in .3s ease-out; }
@keyframes pop-in { from { transform: scale(.94); opacity: .4; } to { transform: none; opacity: 1; } }

/* Konfeti */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 30; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { top: 110%; transform: rotate(720deg) translateX(40px); } }

/* Final unvanları */
.titles { display: grid; gap: 8px; margin-top: 16px; text-align: left; }
.titles:empty { display: none; }
.title-card { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; animation: pop-in .4s ease-out backwards; }
.title-card:nth-child(2) { animation-delay: .1s; }
.title-card:nth-child(3) { animation-delay: .2s; }
.title-card:nth-child(4) { animation-delay: .3s; }
.title-card:nth-child(5) { animation-delay: .4s; }
.title-card:nth-child(6) { animation-delay: .5s; }
.title-card .t-icon { font-size: 1.8rem; }
.title-card small { display: block; color: var(--muted); font-weight: 500; }

@media (prefers-reduced-motion: reduce) {
  main.phone.hit, .order.pop, .title-card, .glitching .grid, .glitching .order, .meteor { animation: none !important; }
  .confetti { display: none; }
}
