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

body {
  font-family: 'Rubik', sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  transition: background .3s, color .3s;
}

/* THEMES */
body.dark  { background: #121213; color: #fff; }
body.light { background: #fff; color: #121213; }

.dark {
  --border: #3a3a3c;
  --tile-empty: #121213;
  --tile-empty-border: #565758;
  --tile-filled-border: #999;
  --correct: #538d4e;
  --present: #b59f3b;
  --absent: #3a3a3c;
  --key-bg: #818384;
  --key-text: #fff;
  --modal-bg: #1a1a1b;
  --toast-bg: #fff;
  --toast-text: #121213;
}

.light {
  --border: #d3d6da;
  --tile-empty: #fff;
  --tile-empty-border: #d3d6da;
  --tile-filled-border: #878a8c;
  --correct: #6aaa64;
  --present: #c9b458;
  --absent: #787c7e;
  --key-bg: #d3d6da;
  --key-text: #121213;
  --modal-bg: #fff;
  --toast-bg: #121213;
  --toast-text: #fff;
}

/* HEADER */
header {
  width: 100%;
  max-width: 500px;
  display: grid;
  grid-template-columns: 0.3fr 1fr 1fr;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: 0.15em; }

.home-link {
  width: 64px;
  font-family: 'Rubik', sans-serif;
  font-size: 0.72rem;
  color: var(--key-text);
  text-decoration: none;
  opacity: 0.6;
  transition: opacity .2s;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.home-link:hover { opacity: 1; }

.header-btns { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }

.logo_image {
  height: 40px;
  width: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: inherit;
  padding: 4px;
  border-radius: 4px;
}

.mode-toggle {
  display: flex;
  gap: 3px;
  background: var(--absent);
  border-radius: 20px;
  padding: 3px;
}

.mode-btn {
  padding: 4px 10px;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  font-family: 'Rubik', sans-serif;
  font-size: 0.72rem;
  font-weight: 500;
  transition: all .2s;
  background: transparent;
  color: var(--key-text);
  white-space: nowrap;
}
.mode-btn.active { background: var(--correct); color: #fff; }

/* GRID */
#game {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 500px;
  padding: 16px 16px 0;
}

#grid {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 5px;
  width: 100%;
  max-width: 330px;
}

.row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }

.tile {
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid var(--tile-empty-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  font-family: 'Rubik', sans-serif;
  text-transform: uppercase;
  transition: transform .1s;
  background: var(--tile-empty);
  color: inherit;
  user-select: none;
}

.tile.filled { border-color: var(--tile-filled-border); animation: pop .1s ease; }
.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.reveal  { animation: flip .5s ease forwards; }
.tile.shake   { animation: shake .5s ease; }

@keyframes pop   { 0% { transform: scale(1) } 50% { transform: scale(1.12) } 100% { transform: scale(1) } }
@keyframes flip  { 0% { transform: rotateX(0) } 50% { transform: rotateX(-90deg) } 100% { transform: rotateX(0) } }
@keyframes shake { 0%, 100% { transform: translateX(0) } 10%, 50%, 90% { transform: translateX(-4px) } 30%, 70% { transform: translateX(4px) } }

/* KEYBOARD */
#keyboard {
  width: 100%;
  max-width: 500px;
  padding: 35px 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.kb-row { display: flex; gap: 4px; justify-content: center; width: 100%; }

.key {
  height: 56px;
  min-width: 28px;
  padding: 10px 0 4px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-family: 'Rubik', sans-serif;
  font-size: 0.75rem;
  font-weight: 1000;
  background: var(--key-bg);
  color: var(--key-text);
  transition: all .1s;
  flex: 1;
  max-width: 42px;
  touch-action: manipulation;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  -ms-border-radius: 5px;
  -o-border-radius: 5px;
}
.key.wide { max-width: 80px; font-size: 0.62rem; }
.key.correct { background: var(--correct); color: #fff; }
.key.present { background: var(--present); color: #fff; }
.key.absent  { background: var(--absent);  color: #fff; }
.key:active  { transform: scale(0.93); }

/* TOAST */
.toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--toast-bg);
  color: var(--toast-text);
  padding: 10px 20px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.95rem;
  z-index: 999;
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; }

/* MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal {
  background: var(--modal-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  max-width: 420px;
  width: 100%;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 { font-size: 1.2rem; font-weight: 700; text-align: center; margin-bottom: 16px; letter-spacing: .1em; }
.modal p  { font-size: 0.9rem; line-height: 1.6; margin-bottom: 12px; color: inherit; opacity: .9; }

.example-tiles { display: flex; gap: 4px; margin: 8px 0; }

.ex-tile {
  width: 44px;
  height: 44px;
  border: 2px solid var(--tile-filled-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  font-family: 'Rubik', sans-serif;
  flex-shrink: 0;
}
.ex-tile.correct { background: var(--correct); border-color: var(--correct); color: #fff; }
.ex-tile.present { background: var(--present); border-color: var(--present); color: #fff; }
.ex-tile.absent  { background: var(--absent);  border-color: var(--absent);  color: #fff; }

.close-btn {
  position: absolute;
  top: 12px; right: 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.4rem;
  color: inherit;
  line-height: 1;
}

.play-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  background: var(--correct);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: 'Rubik', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .05em;
}

.divider { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* DAILY REVEAL */
#daily-reveal {
  width: 100%;
  max-width: 500px;
  padding: 8px 16px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

#reveal-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-family: 'Rubik', sans-serif;
  font-size: 0.82rem;
  opacity: 0.45;
  transition: opacity .2s, border-color .2s;
  width: 100%;
  justify-content: space-between;
}
#reveal-btn.unlocked { opacity: 1; border-color: var(--correct); }
#reveal-btn.unlocked:hover { background: var(--correct)18; }

#reveal-date { font-weight: 600; letter-spacing: 0.03em; }
#reveal-lock  { font-size: 0.78rem; }

#reveal-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border: 1px solid var(--correct);
  border-radius: 8px;
  width: 100%;
  background: var(--correct)14;
}
#reveal-label { font-size: 0.8rem; opacity: 0.7; }
#reveal-word  { font-size: 1.4rem; font-weight: 700; letter-spacing: 0.12em; }

/* RESPONSIVE */
@media (max-width: 480px) {
  header { padding: 10px 12px; }
  h1 { font-size: 1.3rem; letter-spacing: 0.1em; }
  .logo_image { height: 28px; }
  .mode-btn { padding: 3px 8px; font-size: 0.68rem; }
  .icon-btn { font-size: 1rem; padding: 3px; }

  #game { padding: 12px 12px 0; }
  #grid { max-width: 290px; gap: 4px; }
  .row  { gap: 4px; }
  .tile { font-size: 1.6rem; }

  #keyboard { padding: 8px 4px 12px; gap: 5px; }
  .kb-row   { gap: 3px; }
  .key      { height: 46px; font-size: 0.7rem; min-width: 24px; }
  .key.wide { font-size: 0.58rem; max-width: 64px; }
}

@media (max-width: 360px) {
  h1 { font-size: 1.1rem; }
  .tile { font-size: 1.3rem; }
  #grid { max-width: 260px; }
  .key  { height: 42px; font-size: 0.65rem; }
  .mode-btn { padding: 3px 6px; font-size: 0.62rem; }
}
