:root {
  --bg: #0f1115;
  --panel: #171a21;
  --tile-border: #2c313c;
  --tile-empty: #15181f;
  --text: #e8eaf0;
  --muted: #8b93a3;
  --correct: #2f9e6e;
  --present: #c9a227;
  --absent: #3a3f4b;
  --key-bg: #4a5060;
  --accent: #6d8dff;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
#app {
  max-width: 500px;
  margin: 0 auto;
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 8px env(safe-area-inset-bottom);
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 6px;
  border-bottom: 1px solid #22262f;
}
.logo {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 4px;
  background: linear-gradient(135deg, #6d8dff, #9d6dff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.header-right { display: flex; gap: 4px; }
.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s, background .15s;
}
.icon-btn:hover { color: var(--text); background: #1d212b; }

.ad-slot { display: none; margin: 8px auto; min-height: 60px; width: 100%; background: var(--panel); border-radius: 10px; text-align: center; }
.ad-slot.on { display: block; }
.ad-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 0 8px;
}
#board {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 5px;
  width: min(330px, 88vw);
  margin: 0 auto;
}
.row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}
.tile {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.9rem;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--tile-empty);
  border: 2px solid var(--tile-border);
  border-radius: 6px;
  transition: transform .1s;
}
.tile.filled { border-color: #4a5060; animation: pop .1s; }
.tile.reveal { animation: flip .5s forwards; }
.tile.correct { background: var(--correct); border-color: var(--correct); color: #fff; }
.tile.present { background: var(--present); border-color: var(--present); color: #fff; }
.tile.absent  { background: var(--absent);  border-color: var(--absent);  color: #fff; }
.tile.ex { width: 42px; font-size: 1.4rem; }
.row.shake { animation: shake .5s; }
@keyframes pop { 50% { transform: scale(1.1); } }
@keyframes flip {
  0% { transform: rotateX(0); }
  50% { transform: rotateX(-90deg); }
  100% { transform: rotateX(0); }
}
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

#keyboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 2px;
}
.kb-row { display: flex; gap: 5px; justify-content: center; }
.key {
  flex: 1;
  max-width: 48px;
  height: 58px;
  border: none;
  border-radius: 6px;
  background: var(--key-bg);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, transform .05s;
  font-family: inherit;
}
.key:active { transform: scale(.94); }
.key.wide { max-width: 74px; flex: 1.6; font-size: .72rem; letter-spacing: .5px; }
.key.correct { background: var(--correct); }
.key.present { background: var(--present); }
.key.absent  { background: #23262e; color: #5a6172; }

#toast {
  position: fixed;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  background: #e8eaf0;
  color: #0f1115;
  padding: 12px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: .95rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
  z-index: 50;
  max-width: 86vw;
  text-align: center;
}
#toast.show { opacity: 1; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  animation: fadeIn .2s;
}
.modal-overlay[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  background: var(--panel);
  border: 1px solid #262b36;
  border-radius: 14px;
  padding: 24px 22px;
  width: min(420px, 92vw);
  max-height: 86vh;
  max-height: 86dvh;
  overflow-y: auto;
  position: relative;
  animation: slideUp .25s;
}
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } }
.modal h2 { font-size: 1.15rem; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 12px; }
.modal h3 { font-size: .85rem; letter-spacing: .6px; text-transform: uppercase; margin: 16px 0 8px; color: var(--muted); }
.modal p { color: #c6cbd6; line-height: 1.55; margin: 8px 0; font-size: .95rem; }
.modal ul { margin: 8px 0 8px 20px; color: #c6cbd6; line-height: 1.6; font-size: .95rem; }
.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 26px;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }
.example { margin: 14px 0; }
.example-row { display: flex; gap: 5px; margin-bottom: 6px; }
.daily-note { color: var(--muted); font-style: italic; }

.stat-row { display: flex; justify-content: space-around; margin: 8px 0 4px; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat-num { font-size: 2rem; font-weight: 700; }
.stat-label { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; text-align: center; max-width: 76px; }
#distribution { display: flex; flex-direction: column; gap: 4px; }
.dist-row { display: flex; align-items: center; gap: 8px; }
.dist-label { width: 10px; font-weight: 600; font-size: .85rem; }
.dist-bar {
  background: var(--absent);
  color: #fff;
  font-size: .8rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  min-width: 28px;
  text-align: right;
}
.dist-bar.hl { background: var(--correct); }
#result-block { text-align: center; margin-top: 6px; }
#result-headline { font-size: 1.3rem; text-transform: none; letter-spacing: 0; color: var(--text); }
.next-word { color: var(--muted); font-size: .9rem; }
.share-btn {
  margin-top: 12px;
  background: var(--correct);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 13px 30px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: filter .15s;
}
.share-btn:hover { filter: brightness(1.1); }

@media (max-height: 640px) {
  .key { height: 48px; }
  #board { width: min(290px, 84vw); }
  .logo { font-size: 22px; }
}
@media (prefers-color-scheme: light) {
  /* Dark by design; light scheme kept dark for brand consistency. */
}
