/* ===========================================================
   İngilizce Kelime Oyunu - Stiller
   6 yaş için: büyük, renkli, sade, dokunmatik dostu
   =========================================================== */

:root {
  --bg1: #7c4dff;
  --bg2: #18b6ff;
  --card: #ffffff;
  --ink: #2b2b40;
  --muted: #7a7a94;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #ffd23f;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  --radius: 24px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* hidden özniteliği her zaman gizlesin (display kuralları ezmesin) */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: "Comic Sans MS", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  background-attachment: fixed;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  height: 100dvh;
  overflow: hidden; /* pencerede kaydırma çubuğu olmasın */
  user-select: none;
}

.wrap {
  width: 100%;
  max-width: 780px;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.screen {
  display: none;
}
.screen.active {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  animation: pop 0.35s ease;
}
/* Giriş ve sonuç ekranı ortalanır; içerik sığmazsa kart kendi içinde kayar */
#screen-login.active,
#screen-result.active {
  justify-content: center;
  align-items: center;
}

@keyframes pop {
  from {
    transform: scale(0.96);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

h1 {
  text-align: center;
  font-size: clamp(28px, 6vw, 44px);
  margin: 6px 0 2px;
  color: var(--bg1);
}
.subtitle {
  text-align: center;
  color: var(--muted);
  margin: 0 0 20px;
  font-size: 18px;
}

/* --- Giriş ekranı --- */
.emoji-title {
  font-size: 72px;
  text-align: center;
  margin-bottom: 4px;
}

.name-input {
  width: 100%;
  font-size: 24px;
  padding: 18px 20px;
  border: 3px solid #e6e6f0;
  border-radius: 18px;
  text-align: center;
  outline: none;
  margin-bottom: 16px;
  font-family: inherit;
}
.name-input:focus {
  border-color: var(--bg1);
}

.btn {
  display: block;
  width: 100%;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 24px;
  font-weight: bold;
  padding: 18px;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(135deg, #ff7eb3, #ff5f8f);
  box-shadow: 0 6px 0 #e0356b;
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #e0356b;
}
.btn.green {
  background: linear-gradient(135deg, #4ade80, #22c55e);
  box-shadow: 0 6px 0 #15803d;
}
.btn.green:active {
  box-shadow: 0 2px 0 #15803d;
}
.btn.small {
  font-size: 18px;
  padding: 12px 18px;
  width: auto;
  display: inline-block;
}

.choose-label {
  text-align: center;
  color: var(--muted);
  margin: 6px 0 12px;
  font-size: 16px;
}
.mode-btn {
  margin-bottom: 12px;
}

.link {
  display: block;
  text-align: center;
  margin-top: 18px;
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
}
.link:hover {
  color: var(--bg1);
}

/* --- Oyun ekranı üst bar --- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  color: #fff;
  font-size: 20px;
  font-weight: bold;
}
.pill {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 8px 16px;
  backdrop-filter: blur(4px);
}
.pill.score {
  background: var(--yellow);
  color: #7a5b00;
}

.progress {
  height: 14px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 18px;
}
.progress > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--yellow);
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* --- Sesli soru --- */
.listen {
  text-align: center;
  margin: 4px 0 14px;
}
.speaker {
  font-size: clamp(30px, 8vw, 40px);
  width: clamp(84px, 20vw, 110px);
  height: clamp(84px, 20vw, 110px);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #ffd23f, #ffa41b);
  box-shadow: 0 8px 0 #d98200;
  transition: transform 0.1s;
  animation: bounce 1.6s infinite;
}
.speaker:active {
  transform: scale(0.92);
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.listen p {
  color: #fff;
  font-size: 20px;
  margin-top: 12px;
}

/* --- Cevap seçenekleri --- */
.options {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 14px;
}
.option {
  background: var(--card);
  border: 5px solid transparent;
  border-radius: 22px;
  cursor: pointer;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px;
  box-shadow: var(--shadow);
  transition: transform 0.08s, border-color 0.15s;
  overflow: hidden;
}
.option:active {
  transform: scale(0.95);
}
.opt-visual {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(48px, 14vw, 88px);
  line-height: 1;
}
.opt-visual img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.opt-label {
  margin-top: 6px;
  font-size: clamp(20px, 5vw, 30px);
  font-weight: bold;
  color: var(--ink);
  text-transform: lowercase;
  letter-spacing: 0.5px;
  line-height: 1.1;
  text-align: center;
}
.opt-tr {
  display: block;
  font-size: 0.6em;
  font-weight: normal;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  margin-top: 1px;
}
.option.correct {
  border-color: var(--green);
  animation: shake-correct 0.5s;
}
.option.wrong {
  border-color: var(--red);
  opacity: 0.6;
}
@keyframes shake-correct {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.12); }
}

/* --- Geri bildirim balonu --- */
.feedback {
  text-align: center;
  font-size: 28px;
  font-weight: bold;
  color: #fff;
  min-height: 34px;
  margin-top: 12px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* ===== Konuşma / Sorular ekranı ===== */
.pill-btn {
  border: none;
  font-family: inherit;
  font-size: inherit;
  font-weight: bold;
  color: #fff;
  cursor: pointer;
}
.talk-card {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  text-align: center;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin: 6px 0 14px;
  overflow-y: auto;
}
.talk-en {
  font-size: clamp(26px, 7vw, 44px);
  font-weight: bold;
  color: var(--ink);
  line-height: 1.25;
}
.talk-tr {
  font-size: clamp(16px, 4.5vw, 24px);
  color: var(--muted);
}
.talk-nav {
  display: flex;
  gap: 12px;
}
.talk-nav .btn {
  flex: 1;
  margin: 0;
}
.btn.ghost-btn {
  background: linear-gradient(135deg, #cbd5e1, #94a3b8);
  box-shadow: 0 6px 0 #64748b;
}
.btn.ghost-btn:active {
  box-shadow: 0 2px 0 #64748b;
}
.btn:disabled {
  opacity: 0.4;
  box-shadow: none;
  transform: none;
  cursor: default;
}

/* --- Sonuç ekranı --- */
.result-card {
  width: 100%;
  max-width: 560px;
  max-height: 100%;
  overflow-y: auto;
  padding: 22px;
}
.result-emoji {
  font-size: clamp(52px, 12vw, 72px);
  text-align: center;
  line-height: 1;
}
.big-score {
  text-align: center;
  font-size: clamp(40px, 10vw, 56px);
  font-weight: bold;
  color: var(--bg1);
  margin: 2px 0;
}
.result-text {
  text-align: center;
  font-size: 18px;
  color: var(--muted);
  margin: 0 0 16px;
}

/* Seviye atlama afişi */
.levelup {
  background: linear-gradient(135deg, #ffd23f, #ffa41b);
  color: #6b4a00;
  font-weight: bold;
  text-align: center;
  padding: 12px;
  border-radius: 14px;
  margin-bottom: 12px;
  font-size: 18px;
  animation: pop 0.4s ease;
}

/* Seviye / bölüm satırı */
.level-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.level-badge {
  background: var(--bg1);
  color: #fff;
  font-weight: bold;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 14px;
  white-space: nowrap;
}
.level-bar {
  flex: 1;
  height: 14px;
  background: #ececf5;
  border-radius: 999px;
  overflow: hidden;
}
.level-bar > span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #4ade80, #22c55e);
  border-radius: 999px;
  transition: width 0.6s ease;
}
.level-next {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* İstatistik kutuları */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.stat {
  background: #f5f5fb;
  border-radius: 12px;
  padding: 10px 4px;
  text-align: center;
}
.stat b {
  display: block;
  font-size: 20px;
  color: var(--bg1);
}
.stat span {
  font-size: 11px;
  color: var(--muted);
}

/* Gelişim grafiği */
.devwrap {
  margin-bottom: 16px;
}
.devtitle {
  font-size: 14px;
  font-weight: bold;
  color: var(--muted);
  margin-bottom: 6px;
}
.chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 70px;
  padding: 6px 4px 0;
  background: #f5f5fb;
  border-radius: 12px;
}
.bar-col {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: flex-end;
}
.bar {
  width: 100%;
  background: #c7c9e8;
  border-radius: 5px 5px 0 0;
  transition: height 0.5s ease;
}
.bar.last {
  background: linear-gradient(180deg, #7c4dff, #18b6ff);
}

/* Sıralama (katlanabilir) */
.boardwrap {
  margin-top: 14px;
}
.boardwrap summary {
  cursor: pointer;
  font-weight: bold;
  color: var(--bg1);
  padding: 6px 0;
  font-size: 15px;
}

/* --- Skor tablosu --- */
.board {
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
}
.board li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-radius: 14px;
  background: #f5f5fb;
  margin-bottom: 8px;
  font-size: 18px;
}
.board li .rank {
  font-weight: bold;
  color: var(--bg1);
  margin-right: 10px;
}
.board li.me {
  background: #fff3c9;
}

/* --- Konfeti --- */
#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

/* --- Admin --- */
/* Giriş kartı ortada, uygun genişlikte */
#screen-login .card {
  width: 100%;
  max-width: 440px;
}

/* Admin sayfası oyundan farklı: normal akış + kaydırma serbest */
.admin-body {
  background: #f1f2f8;
  display: block;
  color: var(--ink);
  padding: 0;
  height: auto;
  min-height: 100dvh;
  overflow: auto;
}
.admin-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.admin-header h1 {
  color: var(--bg1);
  text-align: left;
  margin: 0;
  font-size: 28px;
}
.panel {
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 22px;
}
.panel h2 {
  margin-top: 0;
  font-size: 20px;
}
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}
.field input {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  border: 2px solid #e6e6f0;
  border-radius: 10px;
  outline: none;
  font-family: inherit;
}
.field input:focus {
  border-color: var(--bg1);
}
.dup-hint {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  min-height: 14px;
  font-weight: bold;
}
.dup-hint.warn {
  color: #b91c1c;
}
.dup-hint.ok {
  color: #15803d;
}
.admin-btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  font-weight: bold;
  padding: 12px 22px;
  border-radius: 10px;
  color: #fff;
  background: var(--bg1);
}
.admin-btn.danger {
  background: var(--red);
  padding: 8px 14px;
  font-size: 14px;
}
.admin-btn.ghost {
  background: #e6e6f0;
  color: var(--ink);
}

table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid #eee;
  font-size: 15px;
}
th {
  color: var(--muted);
  font-size: 13px;
}
.wordvis {
  font-size: 34px;
}
.wordvis img {
  height: 40px;
  width: 40px;
  object-fit: contain;
  vertical-align: middle;
}

.msg {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 15px;
  display: none;
}
.msg.show {
  display: block;
}
.msg.ok {
  background: #dcfce7;
  color: #166534;
}
.msg.err {
  background: #fee2e2;
  color: #991b1b;
}

/* ===== Responsive ===== */

/* Telefon (dikey) */
@media (max-width: 480px) {
  body {
    padding: 12px;
  }
  .card {
    padding: 20px 16px;
  }
  .topbar {
    font-size: 16px;
  }
  .pill {
    padding: 6px 12px;
  }
  .options {
    gap: 12px;
  }
  .listen p {
    font-size: 17px;
  }
  .feedback {
    font-size: 24px;
  }
}

/* Çok küçük telefonlar */
@media (max-width: 360px) {
  .options {
    gap: 10px;
  }
  .opt-label {
    font-size: 18px;
  }
  .topbar {
    font-size: 14px;
  }
  .pill {
    padding: 5px 9px;
  }
}

/* Yatay (landscape) telefon: dikey alan az -> 4 sütun, küçük buton */
@media (orientation: landscape) and (max-height: 560px) {
  .options {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: 1fr;
    max-width: 100%;
  }
  .speaker {
    width: 68px;
    height: 68px;
    font-size: 26px;
    animation: none;
  }
  .listen {
    margin: 2px 0 10px;
  }
  .listen p {
    font-size: 14px;
    margin-top: 6px;
  }
  .opt-label {
    font-size: clamp(14px, 2.5vw, 20px);
  }
  .progress {
    margin-bottom: 10px;
  }
}

/* Tablet ve üstü: kartlar çok büyümesin */
@media (min-width: 700px) {
  .wrap {
    max-width: 720px;
  }
}

/* ===== Ana ekrana ekle (PWA) ===== */
.install-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  background: linear-gradient(135deg, #7c4dff, #18b6ff);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.25);
}
.install-text {
  font-weight: bold;
  font-size: 15px;
}
.install-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
.install-btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: bold;
  font-size: 15px;
  padding: 10px 18px;
  border-radius: 12px;
}
.install-btn.yes {
  background: #ffd23f;
  color: #6b4a00;
}
.install-btn.no {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.ios-help {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.ios-help-card {
  background: #fff;
  border-radius: 20px;
  padding: 26px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
}
.ios-help-emoji {
  font-size: 48px;
}
.ios-help-card p {
  font-size: 17px;
  color: var(--ink);
  margin: 10px 0;
}
.ios-help-card .btn {
  margin-top: 14px;
}
