:root {
  color-scheme: dark;
  --bg: #121417;
  --panel: #1c2026;
  --panel-strong: #252a32;
  --text: #f2f0e8;
  --muted: #a8adbb;
  --line: #343b46;
  --gold: #e5b94e;
  --teal: #30c7b5;
  --rose: #e76071;
  --exact: #238c62;
  --partial: #b08a2e;
  --miss: #b71925;
  --shadow: rgba(0, 0, 0, 0.32);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(48, 199, 181, 0.16), transparent 34rem),
    linear-gradient(135deg, #121417 0%, #191a20 44%, #101317 100%);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.shell {
  width: min(1800px, calc(100% - 12px));
  height: 100vh;
  margin: 0 auto;
  padding: 10px 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(28, 32, 38, 0.84);
  box-shadow: 0 18px 50px var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 6px;
  flex: 0 0 auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11151a;
}

.mode-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: nowrap;
}

.mode-button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.mode-button.active {
  border-color: rgba(255, 255, 255, 0.28);
  background: var(--teal);
  color: #071412;
}

h2,
p {
  margin-top: 0;
}

.site-logo {
  display: block;
  width: min(520px, 100%);
  height: auto;
}

h2 {
  margin-bottom: 16px;
  font-size: 1rem;
}

.game-layout {
  display: grid;
  grid-template-columns: clamp(150px, 12vw, 190px) minmax(0, 1fr) clamp(150px, 12vw, 190px);
  gap: 8px;
  margin-top: 8px;
  min-height: 0;
}

.panel,
.play-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(28, 32, 38, 0.92);
  box-shadow: 0 14px 34px var(--shadow);
}

.panel {
  padding: 8px 10px;
}

.play-panel {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  order: 2;
  display: flex;
  flex-direction: column;
}

.help-panel {
  order: 1;
  align-self: stretch;
}

.help-panel,
.side-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.side-panel {
  order: 3;
  align-self: stretch;
}

.answer-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.help-panel h2 {
  margin: 0 0 4px;
}

.hint-card {
  display: grid;
  gap: 10px;
}

.hint-card h2 {
  margin: 0;
}

.hint-text {
  min-height: 90px;
  margin: 0;
  padding: 10px;
  border: 1px solid rgba(48, 199, 181, 0.35);
  border-radius: 6px;
  background: rgba(48, 199, 181, 0.08);
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.hint-text[hidden] {
  display: none;
}

.ad-slot {
  display: grid;
  place-items: center;
  min-height: 280px;
  margin-top: auto;
  border: 1px dashed rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.guess-form {
  position: relative;
  z-index: 20;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(28, 32, 38, 0.96);
}

.guess-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.slot-search {
  position: relative;
  min-width: 0;
}

.slot-options {
  position: absolute;
  top: calc(100% + 6px);
  right: -74px;
  left: 0;
  z-index: 40;
  display: grid;
  max-height: min(430px, 58vh);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #11151a;
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.42);
}

.slot-option {
  appearance: none;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 52px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: #2d3440;
  color: var(--text);
  text-align: left;
}

.slot-option:last-child {
  border-bottom: 0;
}

.slot-option:focus {
  outline: none;
}

.slot-option:hover,
.slot-option:focus,
.slot-option:active,
.slot-option.active {
  background: #18263d;
}

.slot-option:hover strong,
.slot-option.active strong,
.slot-option:hover span,
.slot-option.active span {
  color: #fff;
}

.slot-option .slot-icon-fallback {
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.slot-option strong,
.slot-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot-option-text {
  display: grid;
  min-width: 0;
}

.slot-option strong {
  font-size: 0.86rem;
}

.slot-option span {
  color: var(--muted);
  font-size: 0.76rem;
}

.slot-icon.search-icon {
  width: 40px;
  height: 40px;
  flex-basis: 40px;
  border-radius: 4px;
}

.slot-icon.search-icon .slot-icon-fallback {
  background: #2d3440;
}

input {
  width: 100%;
  min-height: 38px;
  border: 1px solid #4a5361;
  border-radius: 6px;
  padding: 0 14px;
  background: #11151a;
  color: var(--text);
  outline: none;
}

input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(48, 199, 181, 0.18);
}

.input-row > button,
.secondary-button {
  min-height: 38px;
  border-radius: 6px;
  padding: 0 16px;
  background: var(--gold);
  color: #17130a;
  font-weight: 900;
}

.secondary-button {
  width: 100%;
  margin-top: 0;
  background: #2d3440;
  color: var(--text);
}

.status {
  min-height: 24px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.table-wrap {
  width: 100%;
  min-height: 0;
  flex: 1;
  overflow: auto;
}

table {
  width: 100%;
  min-width: 860px;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 4px 5px;
}

th,
td {
  padding: 5px;
  text-align: center;
  vertical-align: middle;
}

th {
  color: var(--text);
  font-size: clamp(0.68rem, 0.84vw, 0.9rem);
  line-height: 1.15;
  text-transform: uppercase;
}

th::after {
  display: block;
  width: 100%;
  height: 3px;
  margin-top: 7px;
  background: #e9edf2;
  content: "";
}

td {
  height: 82px;
  font-size: clamp(0.68rem, 0.88vw, 0.96rem);
}

th:first-child,
td:first-child {
  width: 245px;
}

.tile {
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 3px;
  background: var(--miss);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2), 0 8px 14px rgba(0, 0, 0, 0.2);
  color: #fff;
}

.tile.exact {
  background: linear-gradient(180deg, #20d447, #098b29);
}

.tile.partial {
  background: linear-gradient(180deg, #e9b83f, #9a6911);
}

.tile.miss {
  background: linear-gradient(180deg, #ee202f, #9d111c);
}

.tile.boolean-no {
  background: linear-gradient(180deg, #ee202f, #9d111c);
}

.reveal-tile {
  animation: tile-reveal 900ms cubic-bezier(0.22, 1, 0.36, 1) both;
  transform-origin: center;
}

@keyframes tile-reveal {
  0% {
    opacity: 0;
    transform: rotateX(75deg) translateY(-8px) scale(0.96);
    filter: brightness(1.4);
  }
  55% {
    opacity: 1;
    transform: rotateX(-8deg) translateY(0) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: rotateX(0) translateY(0) scale(1);
    filter: brightness(1);
  }
}

.slot-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.slot-icon {
  display: grid;
  place-items: center;
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
  overflow: visible;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.3);
}

.slot-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.slot-icon-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: #fff;
  font-size: clamp(0.62rem, 0.9vw, 0.82rem);
  font-weight: 900;
}

.slot-text {
  min-width: 0;
}

.slot-text strong {
  display: -webkit-box;
  margin-bottom: 3px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.slot-text span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile strong {
  display: block;
  color: #fff;
  font-size: clamp(0.7rem, 0.88vw, 0.98rem);
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.slot-cell span,
.cell-sub {
  display: block;
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.82);
  font-size: clamp(0.62rem, 0.76vw, 0.82rem);
}

.direction-arrow {
  display: block;
  margin-top: 3px;
  color: #fff;
  font-size: clamp(0.92rem, 1.14vw, 1.18rem);
  line-height: 1;
  font-weight: 900;
}

.direction-arrow.up {
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.35);
}

.direction-arrow.down {
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

.special-list {
  display: grid;
  gap: 3px;
  align-content: center;
}

.special-item {
  display: block;
  color: #fff;
  font-size: clamp(0.56rem, 0.68vw, 0.74rem);
  font-weight: 800;
  line-height: 1.12;
}

.legend-row {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 7px;
  align-items: center;
  margin: 0;
}

.legend-row p,
.note {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.legend {
  width: 18px;
  height: 18px;
  border-radius: 4px;
}

.legend.exact {
  background: var(--exact);
}

.legend.partial {
  background: var(--partial);
}

.legend.miss {
  background: var(--miss);
}

.note {
  margin-top: 0;
  line-height: 1.45;
}

.answer-box {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(28, 32, 38, 0.92);
  box-shadow: 0 14px 34px var(--shadow);
}

.answer-box p {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.answer-box strong,
.answer-box span {
  display: block;
}

.answer-box span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.82rem;
}

.victory-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(12, 15, 18, 0.72);
  backdrop-filter: grayscale(0.9) blur(5px);
}

.victory-overlay[hidden] {
  display: none;
}

.victory-card {
  position: relative;
  z-index: 2;
  width: min(450px, 100%);
  border: 2px solid #35d784;
  border-radius: 8px;
  padding: 34px 34px 28px;
  background: linear-gradient(180deg, #123f28, #102d22);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
  text-align: center;
}

.victory-overlay.fail .victory-card {
  border-color: var(--rose);
  background: linear-gradient(180deg, #421b24, #261318);
}

.victory-overlay.fail .victory-countdown strong {
  color: var(--rose);
}

.victory-overlay.fail .victory-action.retry {
  border-color: rgba(231, 96, 113, 0.9);
  background: var(--rose);
  color: #fff;
}

.confetti-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  border-radius: 2px;
  opacity: 0;
  animation: confetti-fall var(--d) ease-out var(--delay) forwards;
}

@keyframes confetti-fall {
  0% {
    opacity: 0;
    transform: translate3d(0, -20px, 0) rotate(0deg);
  }
  12% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--x), 105vh, 0) rotate(var(--r));
  }
}

.victory-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 1.35rem;
  line-height: 1;
}

.victory-card h1 {
  margin: 0 0 20px;
  color: #fff;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1;
}

.victory-answer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 18px;
  text-align: left;
}

.victory-answer p,
.victory-countdown p {
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 800;
}

.victory-answer strong {
  display: block;
  margin-top: 3px;
  color: #fff;
  font-size: 1.6rem;
  line-height: 1.05;
}

.victory-answer span {
  display: block;
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.82rem;
}

.victory-icon-wrap {
  flex: 0 0 auto;
}

.slot-icon.victory-icon {
  width: 66px;
  height: 66px;
  flex-basis: 66px;
  background: rgba(0, 0, 0, 0.25);
}

.victory-stat {
  margin: 0 0 8px;
  color: #fff;
  font-weight: 800;
}

.victory-solves {
  margin: 0 0 22px;
  color: rgba(255, 255, 255, 0.82);
  font-weight: 800;
}

.victory-stat strong,
.victory-countdown strong {
  color: var(--teal);
}

.victory-countdown {
  display: grid;
  gap: 5px;
  margin: 0 auto 22px;
  padding-top: 20px;
  border-top: 2px solid rgba(255, 255, 255, 0.8);
}

.victory-countdown strong {
  font-size: clamp(2rem, 6vw, 2.7rem);
  line-height: 1;
}

.victory-countdown span {
  color: rgba(255, 255, 255, 0.54);
  font-size: 0.82rem;
  font-style: italic;
  font-weight: 700;
}

.victory-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.victory-action {
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 6px;
  padding: 0 20px;
  background: #2d3440;
  color: #fff;
  font-weight: 900;
}

.victory-action.primary {
  border-color: rgba(48, 199, 181, 0.75);
  background: var(--teal);
  color: #0d1618;
}

.victory-action.retry {
  grid-column: 1 / -1;
}

.victory-action[hidden] {
  display: none;
}

.victory-overlay.fail .victory-actions {
  grid-template-columns: 1fr;
}

@media (max-width: 1180px) {
  .hero,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .game-layout {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .help-panel {
    flex-direction: row;
    align-items: center;
    order: 1;
  }

  .side-panel {
    order: 3;
  }

  .help-panel h2 {
    margin: 0;
    white-space: nowrap;
  }

}

@media (max-width: 620px) {
  body {
    overflow: auto;
  }

  .shell {
    width: min(100% - 20px, 1180px);
    height: auto;
    min-height: 100vh;
    padding-top: 10px;
  }

  .brand {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero {
    grid-template-columns: 1fr;
  }

  .mode-switch {
    width: 100%;
  }

  .site-logo {
    width: min(100%, 420px);
  }

  .input-row {
    grid-template-columns: 1fr;
  }

  .input-row > button {
    width: 100%;
  }
}
