:root {
  color-scheme: dark;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  --cream: #fff8f0;
  --gold: #f5c978;
  --rose: #f18aa3;
  --plum: #5d1a49;
  --deep: #180921;
  --muted: #dfc5d1;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  padding: clamp(.8rem, 3vw, 2.5rem);
  color: var(--cream);
  background:
    radial-gradient(circle at 7% 8%, #7a2a63 0, transparent 28%),
    radial-gradient(circle at 94% 90%, #6b234f 0, transparent 31%),
    linear-gradient(145deg, #210c2e 0%, #43133b 54%, #1b0826 100%);
}

button,
input { font: inherit; }

a:focus-visible,
button:focus-visible,
input:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; }

.puzzle-shell { width: min(100%, 1080px); margin: 0 auto; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  color: #ffe9ed;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .14em;
}

.topbar a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: .55rem .85rem;
  border: 1px solid #fff2e83b;
  border-radius: 999px;
  color: inherit;
  letter-spacing: .01em;
  text-decoration: none;
}

.topbar a:hover { background: #fff2e91a; }

.puzzle-card {
  position: relative;
  overflow: hidden;
  border: 1px solid #fff3e62e;
  border-radius: 30px;
  background: #16071edb;
  box-shadow: 0 34px 100px #08020c99, inset 0 0 0 1px #ffffff09;
  backdrop-filter: blur(15px);
}

.puzzle-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  padding: clamp(1.5rem, 4vw, 2.8rem);
  border-bottom: 1px solid #fff2df20;
  background: linear-gradient(135deg, #2a0d36, #541644);
}

.eyebrow {
  margin: 0 0 .65rem;
  color: var(--gold);
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .17em;
  text-transform: uppercase;
}

h1,
h2 { font-family: Georgia, 'Times New Roman', serif; font-weight: 400; }

h1 {
  margin: 0;
  color: #fff8f0;
  font-size: clamp(2.6rem, 6vw, 4.8rem);
  line-height: 1;
  letter-spacing: -.05em;
}

h1 em { color: var(--rose); font-weight: 400; }

.puzzle-header > p {
  max-width: 31rem;
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.wordle-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, .42fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  padding: clamp(1.5rem, 5vw, 3.5rem);
}

.wordle-play { display: grid; justify-items: center; min-width: 0; }

.word-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .42rem;
  width: min(100%, 350px);
}

.word-tile {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 2px solid #926783;
  border-radius: 10px;
  background: #240d30;
  color: #fffaf4;
  font-size: clamp(1.55rem, 5vw, 2.2rem);
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  transition: border-color .15s ease, transform .15s ease;
}

.word-tile.filled { border-color: #d0a4b8; transform: scale(1.035); }
.word-tile.correct { border-color: #4fa57b; background: #337657; }
.word-tile.present { border-color: #d2a84e; background: #a97a2c; }
.word-tile.absent { border-color: #5f5365; background: #4a4050; }
.word-tile.reveal { animation: tile-reveal .45s ease both; }

.word-status {
  min-height: 1.5rem;
  margin: 1rem 0 .75rem;
  color: #f6ced8;
  font-size: .95rem;
  font-weight: 700;
  text-align: center;
}

.word-status.error { animation: status-shake .28s ease; }

.keyboard {
  display: grid;
  gap: .42rem;
  width: min(100%, 560px);
}

.keyboard-row { display: flex; justify-content: center; gap: .32rem; }

.key {
  display: grid;
  place-items: center;
  flex: 1 1 0;
  min-width: 0;
  min-height: 48px;
  padding: .35rem .2rem;
  border: 1px solid #ffffff24;
  border-radius: 8px;
  background: #68445f;
  color: #fffaf4;
  font-size: .84rem;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}

.key.wide { flex: 1.55 1 0; font-size: .72rem; }
.key:hover { background: #80536f; }
.key.correct { background: #337657; }
.key.present { background: #a97a2c; }
.key.absent { background: #403746; color: #c6b9c1; }

.word-rules {
  align-self: start;
  padding: 1.35rem;
  border: 1px solid #fff1e52b;
  border-radius: 20px;
  background: linear-gradient(145deg, #2a0e34d9, #35102fda);
}

.word-rules h2 { margin: 0 0 .7rem; font-size: 1.65rem; }
.word-rules > p { margin: 0; color: var(--muted); line-height: 1.6; }
.legend { display: grid; gap: .65rem; margin-top: 1.2rem; }
.legend p { display: flex; align-items: center; gap: .65rem; margin: 0; color: #e9d5de; font-size: .9rem; }
.legend span { width: 1.55rem; height: 1.55rem; border-radius: 6px; }
.legend .green { background: #337657; }
.legend .gold { background: #a97a2c; }
.legend .grey { background: #4a4050; }

.result-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 1.5rem;
  background: #120619c9;
  text-align: center;
  backdrop-filter: blur(9px);
}

.result-overlay::before {
  content: "";
  position: absolute;
  width: min(88%, 480px);
  height: min(72%, 360px);
  border: 1px solid #ffeac448;
  border-radius: 26px;
  background: linear-gradient(145deg, #301039f2, #641e4ff2);
  box-shadow: 0 28px 80px #07010bb5, 0 0 45px #e6668b33;
}

.result-overlay > * { position: relative; z-index: 1; }
.wordle-page .puzzle-card { backdrop-filter: none; }
.wordle-page .result-overlay { position: fixed; }
.result-icon { margin: 0 0 .4rem; color: var(--gold); font-family: Georgia, 'Times New Roman', serif; font-size: 3.8rem; line-height: 1; }
.result-overlay h2 { margin: 0; font-size: clamp(2.2rem, 6vw, 3.7rem); }
.result-overlay p { max-width: 24rem; margin: .8rem 0 1.2rem; color: #efd9e1; font-size: 1rem; line-height: 1.6; }

.result-overlay a,
.result-overlay button,
.ask-button,
.restart-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: .85rem 1.3rem;
  border: 1px solid #ffe0aa5e;
  border-radius: 14px;
  background: linear-gradient(135deg, #bd426a, #76234f);
  box-shadow: 0 12px 28px #0d03136b;
  color: #fffaf4;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.result-overlay a:hover,
.result-overlay button:hover,
.ask-button:hover,
.restart-button:hover { background: linear-gradient(135deg, #d45278, #8c2d5d); transform: translateY(-2px); }

.questions-layout {
  display: grid;
  grid-template-columns: minmax(0, .88fr) minmax(300px, 1.12fr);
  gap: 1.25rem;
  padding: clamp(1.25rem, 4vw, 2.75rem);
}

.question-panel,
.history-panel {
  border: 1px solid #fff0e329;
  border-radius: 22px;
  background: linear-gradient(145deg, #260c31d9, #35102fda);
}

.question-panel { display: flex; flex-direction: column; align-items: center; padding: clamp(1.4rem, 4vw, 2.4rem); text-align: center; }

.question-count {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: #e5cbd7;
  font-size: .86rem;
  font-weight: 700;
}

.count-track { flex: 1; height: 7px; overflow: hidden; border-radius: 999px; background: #ffffff17; }
.count-fill { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #f1c66e, #ef7898); transition: width .25s ease; }

.answer-orb {
  display: grid;
  place-items: center;
  width: min(58vw, 210px);
  aspect-ratio: 1;
  margin: 2rem 0 1.6rem;
  border: 1px solid #ffe7ca45;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #81355f, #411139 70%);
  box-shadow: inset 0 0 0 10px #ffffff08, 0 22px 55px #0a020f70, 0 0 45px #ee789035;
}

.answer-orb strong {
  color: #fff8ed;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(2.1rem, 8vw, 3.8rem);
  font-weight: 400;
  letter-spacing: .05em;
}

.answer-orb.yes { background: radial-gradient(circle at 35% 30%, #549b76, #24583f 72%); }
.answer-orb.no { background: radial-gradient(circle at 35% 30%, #a44861, #5c1f38 72%); }
.answer-orb.pulse { animation: answer-pulse .38s ease; }

.question-form { display: grid; gap: .75rem; width: 100%; }
.question-form label { color: #ead4dd; font-size: .9rem; font-weight: 700; text-align: left; }
.question-form input {
  width: 100%;
  min-height: 54px;
  padding: .85rem 1rem;
  border: 1px solid #c58fa8;
  border-radius: 14px;
  background: #fffaf4;
  color: #492039;
  font-size: 1rem;
}

.question-form input::placeholder { color: #937383; }
.ask-button { width: 100%; }
.question-error { min-height: 1.35rem; margin: 0; color: #ffc4d1; font-size: .88rem; }

.history-panel { display: flex; flex-direction: column; min-height: 500px; padding: 1.25rem; }
.history-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .25rem .2rem 1rem; }
.history-heading h2 { margin: 0; font-size: 1.65rem; }
.history-heading span { color: var(--gold); font-size: .78rem; font-weight: 700; letter-spacing: .1em; }
.history-empty { margin: auto; color: #c9aebc; line-height: 1.6; text-align: center; }
.history-list { display: grid; gap: .65rem; max-height: 540px; margin: 0; padding: 0 .15rem 0 0; overflow-y: auto; list-style: none; }

.history-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: .75rem;
  align-items: center;
  padding: .85rem;
  border: 1px solid #ffffff1f;
  border-radius: 13px;
  background: #1c0926a8;
}

.history-number { color: #d4aebe; font-size: .76rem; font-weight: 700; }
.history-question { margin: 0; color: #f1e3e8; font-size: .93rem; line-height: 1.4; overflow-wrap: anywhere; }
.history-answer { min-width: 48px; padding: .38rem .45rem; border-radius: 999px; color: #fff; font-size: .72rem; text-align: center; }
.history-answer.yes { background: #397b5b; }
.history-answer.no { background: #8d3450; }

@keyframes tile-reveal {
  0% { transform: rotateX(0); }
  50% { transform: rotateX(90deg); }
  100% { transform: rotateX(0); }
}

@keyframes status-shake {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-7px); }
  70% { transform: translateX(7px); }
}

@keyframes answer-pulse {
  0% { transform: scale(.94); }
  65% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

@media (max-width: 780px) {
  body { padding: .7rem; }
  .topbar { font-size: .65rem; }
  .topbar span { display: none; }
  .puzzle-card { border-radius: 22px; }
  .puzzle-header { display: grid; gap: .8rem; padding: 1.35rem; }
  .puzzle-header > p { font-size: .92rem; line-height: 1.5; }
  .wordle-layout { grid-template-columns: 1fr; padding: 1.25rem; }
  .word-rules { order: -1; padding: 1rem; }
  .word-rules h2 { font-size: 1.35rem; }
  .legend { grid-template-columns: repeat(3, 1fr); gap: .45rem; }
  .legend p { display: grid; justify-items: center; gap: .35rem; font-size: .72rem; text-align: center; }
  .key { min-height: 44px; font-size: .72rem; }
  .key.wide { font-size: .62rem; }
  .questions-layout { grid-template-columns: 1fr; padding: 1rem; }
  .history-panel { min-height: 300px; }
  .answer-orb { margin-block: 1.35rem; }
}

@media (max-width: 390px) {
  .word-grid { gap: .3rem; }
  .keyboard-row { gap: .2rem; }
  .key { min-height: 41px; padding-inline: .05rem; }
  .legend { grid-template-columns: 1fr; }
  .legend p { display: flex; justify-items: initial; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
