/* ── Reset & Tokens ─────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box; margin: 0; padding: 0;
  -webkit-tap-highlight-color: transparent;
}
:root {
  --bg:    #E0F7FA;
  --white: #ffffff;
  --pri:   #00BCD4;
  --prid:  #00838F;
  --ok:    #4CAF50;
  --err:   #F44336;
  --warn:  #F9A825;
  --text:  #1a1a1a;
  --sub:   #555555;
  --bdr:   #B2EBF2;
  --r:     16px;
  --sh:    0 4px 14px rgba(0,0,0,.12);
}
body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100vh; overflow-x: hidden;
  touch-action: manipulation; user-select: none;
}

/* ── Screens ────────────────────────────────────────────────────── */
.screen { display: none; min-height: 100vh; flex-direction: column; }
.screen.active { display: flex; }

/* ── Splash ─────────────────────────────────────────────────────── */
#splash { align-items: center; justify-content: center; }
.splash-inner { text-align: center; padding: 32px; }
.splash-icon { font-size: 88px; line-height: 1; margin-bottom: 12px; }
#splash h1 { font-size: 42px; font-weight: 900; margin-bottom: 6px; }
.splash-sub { font-size: 22px; color: var(--sub); margin-bottom: 40px; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn-lg {
  background: var(--pri); color: var(--white); border: none;
  border-radius: var(--r); padding: 20px 52px;
  font-size: 26px; font-weight: 700; cursor: pointer;
  min-height: 72px; box-shadow: var(--sh);
  transition: transform .1s;
}
.btn-lg:active { transform: scale(.95); }
.btn-pri {
  background: var(--pri); color: var(--white); border: none;
  border-radius: 12px; padding: 14px 28px;
  font-size: 18px; font-weight: 600; cursor: pointer; min-height: 54px;
  transition: transform .1s;
}
.btn-pri:active { transform: scale(.96); }
.btn-sec {
  background: var(--white); color: var(--prid);
  border: 2px solid var(--pri); border-radius: 12px;
  padding: 12px 24px; font-size: 18px; cursor: pointer; min-height: 52px;
}
.btn-del {
  background: #FFCDD2; color: #C62828;
  border: 2px solid #EF9A9A; border-radius: 12px;
  padding: 12px 24px; font-size: 18px; cursor: pointer; min-height: 52px;
}
.btn-icon {
  background: none; border: none; font-size: 28px;
  cursor: pointer; padding: 8px 10px; line-height: 1;
}
.full-w { width: 100%; }
.pad-h { padding: 0 20px 24px; }

/* ── Dashboard ──────────────────────────────────────────────────── */
.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: var(--white);
  box-shadow: 0 2px 6px rgba(0,0,0,.08); flex-shrink: 0;
}
.top-bar h2 { font-size: 26px; }
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 16px; padding: 20px; flex: 1; align-content: start;
}
.profile-card {
  background: var(--white); border-radius: var(--r);
  padding: 20px 14px; text-align: center; cursor: pointer;
  box-shadow: var(--sh); display: flex; flex-direction: column;
  align-items: center; gap: 10px;
  transition: transform .1s; position: relative;
}
.profile-card:active { transform: scale(.95); }
.avatar {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--bdr); display: flex; align-items: center;
  justify-content: center; font-size: 34px; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.p-name { font-size: 18px; font-weight: 700; }
.p-xp   { font-size: 13px; color: var(--sub); }
.edit-btn {
  position: absolute; top: 8px; right: 8px;
  background: none; border: none; font-size: 18px;
  cursor: pointer; color: var(--sub);
}

/* ── Overlay / Modal ─────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 16px;
}
.overlay[hidden] { display: none; }
.panel {
  background: var(--white); border-radius: var(--r);
  padding: 24px; max-width: 92vw; max-height: 86vh;
  overflow-y: auto; width: 480px;
}
.panel h3 { font-size: 24px; margin-bottom: 16px; }

/* ── Forms ───────────────────────────────────────────────────────── */
label { display: block; font-size: 16px; margin-top: 14px; }
label input[type=text], label select {
  display: block; width: 100%; margin-top: 6px;
  padding: 12px; border: 2px solid var(--bdr);
  border-radius: 8px; font-size: 16px;
  background: var(--white); color: var(--text);
}
input[type=range] { display: block; width: 100%; margin-top: 8px; accent-color: var(--pri); }
.row-label { display: flex; align-items: center; gap: 10px; }
.row-label input[type=checkbox] { width: 22px; height: 22px; }
.word-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 8px; max-height: 180px; overflow-y: auto;
  padding: 8px; border: 1px solid #ddd; border-radius: 8px; margin-top: 8px;
}
.word-chk { display: flex; align-items: center; gap: 5px; font-size: 15px; cursor: pointer; }
.word-chk input { width: 16px; height: 16px; }
.modal-btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

/* ── Game ────────────────────────────────────────────────────────── */
#game { background: var(--bg); }
.game-hdr {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: var(--white);
  box-shadow: 0 2px 4px rgba(0,0,0,.08); flex-shrink: 0;
}
#gameProgress { font-size: 20px; font-weight: 700; flex: 1; }
#gameXP { font-size: 18px; color: var(--prid); }
.timer { font-size: 22px; color: var(--err); font-weight: 700; min-width: 28px; text-align: center; }
.target-display {
  text-align: center; padding: 18px 12px; font-size: 36px;
  font-weight: 900; color: var(--text); min-height: 82px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  letter-spacing: 0.5px;
}
.cards-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 14px; padding: 14px; flex: 1; align-content: start;
}
.word-card {
  background: var(--white); border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(40px, 9vw, 72px); font-weight: 900; cursor: pointer;
  box-shadow: var(--sh); border: 4px solid transparent;
  transition: transform .1s; min-height: 110px;
}
.word-card:active { transform: scale(.96); }
.word-card.correct { animation: pulse .25s ease; border-color: var(--ok); }
.word-card.wrong   { animation: shake .3s ease;  border-color: var(--err); }
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.1)} }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-5px)} 75%{transform:translateX(5px)} }

/* ── High Contrast ───────────────────────────────────────────────── */
.hc, .hc #game { background: #000 !important; color: #fff; }
.hc .word-card  { background: #111; color: #fff; border-color: #666; }
.hc .top-bar, .hc .game-hdr { background: #111; color: #fff; }
.hc .target-display { color: #ddd; }

/* ── End Screen ──────────────────────────────────────────────────── */
#endscreen { align-items: center; justify-content: center; padding: 20px; }
.end-card {
  background: var(--white); border-radius: 20px;
  padding: 28px; text-align: center; max-width: 400px;
  width: 100%; box-shadow: var(--sh);
}
.end-title  { font-size: 44px; margin-bottom: 12px; }
.end-stats  { font-size: 20px; line-height: 1.8; margin-bottom: 16px; }
.badges     { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 10px 0; }
.badge      { background: #FFF9C4; border: 2px solid var(--warn); border-radius: 20px; padding: 5px 14px; font-size: 14px; }
.end-btns   { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 16px; }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (min-width: 600px) {
  .cards-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  .word-card  { min-height: 150px; }
}
@media (max-width: 380px) {
  .word-card  { font-size: 38px; min-height: 90px; }
  .cards-grid { gap: 8px; padding: 8px; }
  .splash-icon { font-size: 64px; }
}
