:root { --brass: #c4a574; --ink: #efe6d8; --dim: #9a9184; --steel: #16120e; --eq-key-scale: 1.3; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  background: #16120e; color: var(--ink);
  overflow: hidden;
}
.shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  gap: 8px;
  padding: 8px;
  overflow: hidden;
}
.hud {
  flex: 0 0 auto;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  background: #2a2218; border: 1px solid #8a6a3e; border-radius: 10px; padding: 8px 12px;
}
a { color: var(--brass); text-decoration: none; letter-spacing: 0.12em; }
button, select, input {
  font: inherit; background: #3a2c20; color: var(--ink); border: 1px solid #8a6a3e;
  border-radius: 8px; padding: 6px 10px; cursor: pointer;
}
#board-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr auto auto auto 1fr;
  grid-template-rows: auto auto auto auto;
  align-items: start;
  justify-content: center;
  gap: 10px 18px;
  padding: 10px 16px 8px;
  width: 100%;
  overflow: visible;
}
.toolbar {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
  justify-content: flex-start;
  padding-left: 0;
}
.toolbar label {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 9rem;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}
.toolbar select {
  min-width: 11rem;
  width: auto;
  min-height: 2.4rem;
  padding: 8px 28px 8px 12px;
}
.toolbar label#kids-lab,
.toolbar label#daily-lab {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-width: auto;
  text-transform: none;
  letter-spacing: 0;
  font-size: 1rem;
  color: var(--ink);
  padding-bottom: 6px;
}
#stage { display: contents; }
#play {
  grid-column: 3;
  grid-row: 1;
  min-height: 0;
  overflow: visible;
  align-self: start;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding-top: 4px;
  margin-top: calc(var(--eq-cell, 2.6rem) * -0.25);
}
#side {
  grid-column: 4;
  grid-row: 1 / 3;
  min-width: 12rem;
  max-width: 24rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-self: start;
  align-self: start;
}
#side label {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}
#daily-lab {
  flex-direction: row !important;
  align-items: center;
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-size: 1rem !important;
  color: var(--ink) !important;
  gap: 8px !important;
}
#keys {
  grid-column: 3;
  grid-row: 2;
}
#result {
  grid-column: 3 / 5;
  grid-row: 3;
}
#msg {
  grid-column: 3;
  grid-row: 4;
}
#side.empty { visibility: hidden; }
#grid { display: flex; flex-direction: column; gap: 6px; }
.play-row { display: flex; align-items: center; gap: 10px; }
.play-row.colors { flex-direction: column; align-items: flex-start; gap: 4px; }
.guess-cells { display: grid; gap: 6px; width: max-content; }
.pip-grid {
  display: grid;
  gap: 6px;
  justify-items: center;
  flex: 0 0 auto;
}
.pip {
  width: 0.85rem; height: 0.85rem;
  border-radius: 50%;
  border: 1px solid #5a4a38;
  background: #2a2218;
  display: grid; place-items: center;
  font-size: 0.55rem; line-height: 1; color: #120e0c;
}
.pip.hit { background: #3ecfff; border-color: #8ee8ff; }
.pip.near { background: #c4a574; border-color: #e8c040; }
.pip.miss { background: #2a2218; border-color: #3a3228; }
.pip.cb-mark { font-weight: 800; }
#keys {
  width: auto;
  max-width: none;
  margin: calc(var(--eq-cell, 2.6rem) * 0.25) 0 0;
  background: #16120e;
  padding: 4px 0 6px;
  z-index: 2;
  overflow: visible;
}
#keys[hidden] { display: none !important; }
body[data-kids-lock="1"] #board-wrap {
  display: grid;
  grid-template-columns: 10.5rem auto minmax(14rem, 1fr);
  grid-template-rows: auto auto auto;
  padding-left: 1.5rem;
  gap: 8px 14px;
}
body[data-kids-lock="1"] .toolbar {
  grid-column: 1;
  grid-row: 1 / 4;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding-left: 0;
}
body[data-kids-lock="1"] #stage { display: contents; }
body[data-kids-lock="1"] #play { grid-column: 2; grid-row: 1; }
body[data-kids-lock="1"] #side { grid-column: 3; grid-row: 1 / 4; }
body[data-kids-lock="1"] #keys { grid-column: 2; grid-row: 2; }
body[data-kids-lock="1"] #result { grid-column: 2; grid-row: 3; }
body[data-kids-lock="1"] #msg { grid-column: 2; grid-row: 4; }
.msg { flex: 0 0 auto; color: var(--brass); min-height: 1.2em; margin: 0; }
.kids-words {
  color: #c4a574;
  font-size: 1.65rem;
  line-height: 1.45;
  font-weight: 600;
  padding: 8px;
  border: 1px dashed #8a6a3e;
  border-radius: 8px;
  min-height: 3rem;
  margin: 0;
}
.kids-words:empty { display: none; }
#first5 {
  border: 1px solid #8a6a3e;
  border-radius: 8px;
  padding: 8px 10px;
  background: #1a1612cc;
}
#first5[hidden] { display: none !important; }
#first5 h3 {
  margin: 0 0 6px;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass);
}
#first5 ol { margin: 0; padding-left: 1.2rem; }
#first5 li { margin: 2px 0; }
.utc-lab { margin: 8px 0 0; font-size: 0.75rem; color: var(--dim); }
@media (max-width: 820px) {
  html, body {
    height: auto;
    min-height: 100%;
    overflow: auto;
  }
  body { overflow: auto; }
  .shell {
    height: auto;
    min-height: 100%;
    overflow: visible;
  }
  #board-wrap {
    overflow: visible;
    height: auto;
    min-height: 0;
  }
  #stage {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: visible;
    grid-template-columns: none;
  }
  #play, #side {
    grid-column: auto;
    overflow: visible;
    max-width: 100%;
  }
  #side.empty { display: none; }
  #keys {
    max-width: 100%;
  }
}
.msg.deny { color: #e07050; animation: blink 0.25s linear 6; }
@keyframes blink { 50% { opacity: 0.2; } }
.hud button.deny { outline: 2px solid #e07050; }
.cell {
  width: var(--eq-cell, 2.6rem); height: var(--eq-cell, 2.6rem); border: 2px solid #5a4a38; border-radius: 6px;
  display: grid; place-items: center; font-weight: 700; letter-spacing: 0.04em;
  font-size: 1.2rem;
}
.cell.typed { border-color: var(--brass); }
.cell.hit { background: #6a5a20; border-color: #e8c040; box-shadow: 0 0 0 2px #e8c04088; }
.cell.near { background: #1a3a48; border-color: #3ecfff; box-shadow: 0 0 0 2px #3ecfff66; }
.cell.miss { background: #2a2218; border-color: #3a3228; color: #9a9184; }
.secret-row {
  display: grid;
  gap: 6px;
  margin: 0 0 10px;
  padding: 0;
  width: max-content;
  outline: 3px solid #c4a574;
  outline-offset: 4px;
  border: none;
  border-radius: 0;
  background: transparent;
  justify-content: start;
}
.secret-row.blink .secret-cell.open {
  animation: blink 0.35s linear 8;
}
.secret-cell { position: relative; overflow: hidden; }
.secret-cell .shutter {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, #2a2218 0 4px, #1a1612 4px 8px);
  border-radius: 4px;
}
.secret-cell.open .shutter { display: none; }
#result {
  color: var(--brass);
  font-family: Cinzel, Palatino, serif;
  font-size: 1.4rem;
}
#result[hidden] { display: none !important; }
#result-title { margin: 0 0 4px; }
#result.win #result-title { color: #e8c040; }
#result.lose #result-title { color: #e07050; }
#result-pay { margin: 0 0 8px; font-size: 1rem; font-family: "Source Sans 3", sans-serif; }
#fx {
  position: fixed; inset: 0; pointer-events: none; z-index: 30;
}
#fx[hidden] { display: none !important; }
.cell.swatch { border-width: 3px; }
.krow { display: flex; gap: 5px; justify-content: center; margin: 6px 0; flex-wrap: nowrap; }
.krow button {
  min-width: 2.4rem;
  min-height: 2.6rem;
  font-size: 1.05rem;
  padding: 8px 10px;
}
body.kids .krow button {
  min-width: 2.6rem;
  min-height: 2.8rem;
  font-size: 1.1rem;
}
.krow button.swatch {
  width: 2.6rem;
  height: 2.6rem;
  min-width: 2.6rem;
  min-height: 2.6rem;
  padding: 0;
}
.cell.swatch.cb-mark,
.krow button.swatch.cb-mark {
  color: #120e0c;
  font-weight: 800;
  font-size: 1.15rem;
  line-height: 1;
  text-shadow: 0 0 3px #efe6d8aa;
}
.modal {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: #0c0a08e8; z-index: 40;
}
.modal[hidden] { display: none !important; }
.panel {
  background: #2a2218; border: 1px solid var(--brass); border-radius: 12px; padding: 20px;
  min-width: 260px;
}
.panel h2 { font-family: Cinzel, Palatino, serif; color: var(--brass); margin: 0 0 8px; }
.win-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
