:root {
  --sky-top: #1d2b8f;
  --sky-mid: #5b2bb5;
  --sky-low: #e0457b;
  --ink: #16163a;
  --card: #ffffff;
  --accent: #ffd23f;
  --good: #2ee6a6;
  --bad: #ff4d6d;
  --text: #ffffff;
  --u: min(1vw, 1vh); /* her en-boy oranında ölçeklenen birim */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--sky-top);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#sky {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 15%, rgba(255,255,255,.18) 0 2px, transparent 3px) 0 0 / 90px 90px,
    radial-gradient(circle at 70% 60%, rgba(255,255,255,.12) 0 1.5px, transparent 2.5px) 0 0 / 130px 130px,
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 55%, var(--sky-low) 100%);
}

/* ---------- HUD ---------- */
#hud {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) 16px 8px;
}
.hud-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 64px;
  font-weight: 800;
  font-size: clamp(18px, calc(var(--u) * 3.6), 34px);
  line-height: 1.1;
}
.hud-label {
  font-size: clamp(10px, calc(var(--u) * 1.6), 14px);
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .75;
}
#lives { letter-spacing: .1em; color: var(--accent); }

/* ---------- Oyun alanı ---------- */
#field {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow: hidden;
}
.word {
  position: absolute;
  top: 0;
  left: 0;
  transform: translate(-50%, -50%);
  padding: .5em .9em;
  min-width: 4.5em;
  border: 0;
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  font-size: clamp(15px, calc(var(--u) * 3.4), 30px);
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 .25em 0 rgba(22,22,58,.35), 0 .6em 1.4em rgba(0,0,0,.25);
  will-change: transform;
}
.word .key {
  display: inline-block;
  margin-right: .45em;
  font-size: .6em;
  opacity: .45;
  vertical-align: middle;
}
.word.hit { background: var(--good); animation: pop .35s ease-out forwards; }
.word.miss { background: var(--bad); color: #fff; animation: shake .35s ease-out; }
.word.reveal { background: var(--accent); }
.word.fade { opacity: 0; transition: opacity .25s ease-out; }

@keyframes pop {
  to { scale: 1.5; opacity: 0; }
}
@keyframes shake {
  20% { rotate: -6deg; } 40% { rotate: 6deg; } 60% { rotate: -4deg; } 80% { rotate: 3deg; }
}

.ground {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 4px;
  background: rgba(255,255,255,.35);
}

/* ---------- Alt hedef çubuğu ---------- */
#prompt-bar {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 10px 16px max(14px, env(safe-area-inset-bottom));
  background: rgba(22,22,58,.55);
  backdrop-filter: blur(6px);
}
#prompt-hint {
  font-size: clamp(11px, calc(var(--u) * 1.8), 15px);
  opacity: .8;
  letter-spacing: .05em;
}
#prompt {
  font-weight: 900;
  font-size: clamp(26px, calc(var(--u) * 6), 56px);
  color: var(--accent);
  line-height: 1.15;
}
#prompt.flip { color: var(--good); }
#combo {
  position: absolute;
  right: 16px;
  top: 10px;
  font-weight: 900;
  font-size: clamp(14px, calc(var(--u) * 2.6), 24px);
  color: var(--good);
}

#banner {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  padding: .4em 1em;
  border-radius: 16px;
  background: var(--accent);
  color: var(--ink);
  font-weight: 900;
  font-size: clamp(20px, calc(var(--u) * 5), 44px);
  text-align: center;
  pointer-events: none;
  animation: banner 1.6s ease-out forwards;
}
@keyframes banner {
  0% { opacity: 0; scale: .7; }
  15% { opacity: 1; scale: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- Paneller ---------- */
.panel {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 460px);
  max-height: 92vh;
  overflow: auto;
  padding: 28px 22px;
  border-radius: 24px;
  background: rgba(22,22,58,.78);
  backdrop-filter: blur(8px);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.panel[hidden], #hud[hidden], #prompt-bar[hidden], #banner[hidden] { display: none; }
.panel.small { width: min(80vw, 320px); }
h1 {
  font-size: clamp(38px, calc(var(--u) * 9), 72px);
  line-height: .95;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -.02em;
}
h2 { font-size: clamp(24px, calc(var(--u) * 5), 40px); font-weight: 900; }
h3 { font-size: 14px; letter-spacing: .08em; text-transform: uppercase; opacity: .75; }
.lead { font-size: clamp(15px, calc(var(--u) * 2.4), 19px); line-height: 1.4; opacity: .92; }
.best { font-size: 15px; opacity: .85; }
.keys { font-size: 12px; opacity: .55; }

.btn {
  border: 0;
  border-radius: 999px;
  padding: 14px 40px;
  font: inherit;
  font-weight: 900;
  font-size: clamp(18px, calc(var(--u) * 3), 24px);
  cursor: pointer;
}
.btn.primary {
  background: var(--accent);
  color: var(--ink);
  box-shadow: 0 5px 0 #c99a00;
}
.btn.primary:active { transform: translateY(3px); box-shadow: 0 2px 0 #c99a00; }

.final { display: flex; flex-direction: column; align-items: center; }
#final-score { font-size: clamp(48px, calc(var(--u) * 11), 88px); font-weight: 900; color: var(--accent); line-height: 1; }
#new-best { color: var(--good); font-weight: 800; font-size: 16px; }

#review-wrap { width: 100%; }
#review {
  list-style: none;
  display: grid;
  gap: 6px;
  margin-top: 8px;
  max-height: 32vh;
  overflow: auto;
}
#review li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,.1);
  font-size: 16px;
}
#review li b { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  .word.hit, .word.miss, #banner { animation-duration: .01s; }
}

/* Dokunmatik cihazlarda klavye ipuçlarını gizle */
@media (hover: none) and (pointer: coarse) {
  .word .key, .keys { display: none; }
}
