:root {
  color-scheme: light;
  --paper: #f7f5ef;
  --panel: #fffdf9;
  --ink: #181e2f;
  --muted: #5f6677;
  --border: #cdd0d8;
  --accent: #294de4;
  --correct: #287850;
  --present: #f4c453;
  --absent: #657084;
  font: 16px/1.5 Arial, "Noto Sans Hebrew", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { min-height: 100svh; margin: 0; }
[hidden] { display: none !important; }
button, input { font: inherit; }
button, summary { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, input:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid #8398ff;
  outline-offset: 3px;
}

.header { border-bottom: 1px solid var(--border); }
.topbar {
  max-width: 1440px;
  min-height: 78px;
  margin-inline: auto;
  padding: 14px clamp(18px, 4vw, 48px);
  display: flex;
  direction: ltr;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 13px;
  font-size: clamp(26px, 3vw, 37px);
  font-weight: 850;
  letter-spacing: -0.07em;
}
.wordmark span { display: flex; gap: 5px; }
.wordmark i, .legend i {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: var(--absent);
}
.wordmark i:first-child, .correct { background: var(--correct); color: #fff; }
.wordmark i:nth-child(2), .present { background: var(--present); color: var(--ink); }
.absent { background: var(--absent); color: #fff; }
nav { display: flex; gap: 10px; }
.button {
  min-height: 43px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 700;
  white-space: nowrap;
  transition: background-color 120ms, border-color 120ms;
}
.primary { background: var(--accent); color: #fff; }
.primary:hover:not(:disabled) { background: #1c3ac6; }
.outline { background: transparent; color: var(--ink); border-color: var(--ink); }
.outline:hover:not(:disabled) { background: #eaeefa; }
.button:disabled { opacity: .56; }
.wide { width: 100%; }

main { max-width: 1240px; margin-inline: auto; padding: clamp(28px, 5vw, 66px) clamp(16px, 4vw, 50px) 24px; }
.workspace {
  display: grid;
  direction: ltr;
  grid-template-columns: minmax(0, 1.23fr) minmax(330px, .97fr);
  gap: clamp(30px, 6vw, 92px);
  align-items: start;
}
h1, h2, p { margin: 0; }
h1 {
  font-size: clamp(43px, 6.1vw, 79px);
  line-height: 1.04;
  font-weight: 850;
  letter-spacing: -.075em;
}
h2 { font-size: clamp(23px, 2.6vw, 35px); line-height: 1.12; letter-spacing: -.035em; }
.subtitle { margin-top: 11px; font-size: clamp(16px, 2vw, 23px); color: var(--muted); }
.panel {
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 16px;
  padding: clamp(17px, 3vw, 29px);
}
.side { display: grid; gap: 18px; }
.setup { align-items: center; padding-block: clamp(0px, 3vw, 37px); }
.setup-intro { padding-inline: clamp(0px, 2vw, 25px); }
.setup-intro .subtitle { max-width: 390px; line-height: 1.55; }
.sample-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 58px));
  gap: 7px;
  margin-top: 29px;
}
.sample-board span {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 29px;
  font-weight: 800;
}
.setup-panel h2 { margin-bottom: 23px; }
.setup-panel form > label, legend { font-weight: 700; }
input {
  min-width: 0;
  width: 100%;
  min-height: 50px;
  padding: 10px 13px;
  border: 1px solid #929bad;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
input::placeholder { color: var(--muted); opacity: 1; }
.secret-field {
  display: flex;
  margin-top: 7px;
  border: 1px solid #929bad;
  border-radius: 8px;
  background: #fff;
}
.secret-field:focus-within { outline: 3px solid #bac8ff; outline-offset: 2px; }
.secret-field input { border: 0; outline: none; background: transparent; }
.secret-field button {
  padding: 0 12px;
  border: 0;
  border-inline-start: 1px solid var(--border);
  background: transparent;
  color: var(--accent);
  font-weight: 700;
}
.hint { font-size: .88rem; color: var(--muted); margin-top: 7px; }
.error { font-size: .94rem; color: #9c263a; margin-block: 9px; }
.word-approval { margin-bottom: 9px; }
fieldset { padding: 0; border: 0; margin: 20px 0; }
legend { padding: 0; margin-bottom: 9px; }
.attempt-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.attempt-options label { position: relative; cursor: pointer; }
.attempt-options input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.attempt-options span {
  display: grid;
  place-items: center;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-weight: 700;
}
.attempt-options input:checked + span { border-color: var(--accent); background: #edf1ff; color: #213bae; }
.attempt-options input:focus-visible + span { outline: 3px solid #8398ff; outline-offset: 3px; }
#play-local { margin-top: 9px; }
.how-to, .credits { font-size: .86rem; color: var(--muted); }
.how-to { margin-top: 17px; }
.how-to p, .credits p { margin-top: 8px; }

.play-board { text-align: center; min-width: 0; }
.phone-keyboard { display: none; margin-top: 10px; min-height: 44px; }
.board {
  --cell: 71px;
  --gap: 7px;
  width: min(100%, calc(var(--letters) * var(--cell) + (var(--letters) - 1) * var(--gap)));
  display: grid;
  gap: var(--gap);
  margin: 24px auto 0;
  cursor: text;
}
.board-row { display: grid; grid-template-columns: repeat(var(--letters), minmax(0, 1fr)); gap: var(--gap); }
.tile {
  min-width: 0;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  background: #fff;
  border: 1px solid #a6aebe;
  border-radius: 9px;
  font-size: clamp(17px, min(4vw, calc(245px / var(--letters))), 37px);
  font-weight: 850;
  line-height: 1;
}
.tile.next { border: 2px solid var(--accent); background: #f1f4ff; }
.tile.correct, .key.correct { border-color: var(--correct); background: var(--correct); color: #fff; }
.tile.present, .key.present { border-color: var(--present); background: var(--present); color: var(--ink); }
.tile.absent, .key.absent { border-color: var(--absent); background: var(--absent); color: #fff; }
.game-status { min-height: 24px; margin-top: 14px; font-weight: 700; }
.game-status.win { color: var(--correct); }
.legend { display: flex; justify-content: center; gap: 17px; flex-wrap: wrap; color: var(--muted); font-size: .84rem; margin-top: 14px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; }
.legend i.correct { background: var(--correct); }
.legend i.present { background: var(--present); }

.guess-panel h2 { margin-bottom: 16px; }
.guess-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
#guess { font-size: 19px; }
.keyboard { display: grid; gap: 6px; margin-top: 18px; }
.key-row { display: flex; justify-content: center; gap: 5px; }
.key {
  flex: 1;
  min-width: 0;
  max-width: 39px;
  min-height: 42px;
  padding: 0;
  border: 1px solid #c1c7d2;
  background: #f8f8fa;
  color: var(--ink);
  border-radius: 6px;
  font-size: 18px;
  font-weight: 750;
}
.key:hover:not(:disabled) { filter: brightness(.94); }
.key.remove { flex: 1.3; max-width: 46px; }
.result-actions { margin-top: 9px; }
.result-word bdi { font-weight: 800; }
.result-actions .button { margin-top: 10px; }
.create-own { display: inline-grid; gap: 2px; justify-items: center; white-space: normal; }
.create-own span { font-size: .85em; font-weight: 600; }
.time-summary { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 13px 0 0; }
.time-summary div { padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
.time-summary dt { color: var(--muted); font-size: .78rem; }
.time-summary dd { margin: 0; font-weight: 750; font-variant-numeric: tabular-nums; }
#refresh-times { min-height: 34px; padding: 4px 10px; font-size: .83rem; }
.sponsor { margin-bottom: 17px; padding: 14px 17px; }
.sponsor-label { font-size: .76rem; color: var(--muted); margin-bottom: 4px; }
.sponsor a { font-weight: 700; }
.fireworks { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 2; }
.firework-bloom { position: absolute; width: 0; height: 0; }
.firework-bloom::before {
  content: '';
  position: absolute;
  width: var(--halo);
  height: var(--halo);
  border-radius: 50%;
  background: radial-gradient(circle, currentColor, transparent 67%);
  animation: firework-glow 1050ms var(--delay) ease-out both;
}
.firework-spark {
  position: absolute;
  inset: 0 auto auto 0;
  width: 7px;
  height: 25px;
  border-radius: 999px;
  background: linear-gradient(#fff8ed 0%, currentColor 38%, transparent 100%);
  filter: drop-shadow(0 0 7px currentColor);
  transform-origin: 50% 5px;
  animation: firework-burst var(--duration) var(--delay) cubic-bezier(.13, .73, .28, 1) both;
}
@keyframes firework-burst {
  0% { opacity: 0; transform: rotate(var(--angle)) scale(.15); }
  11% { opacity: 1; }
  56% { opacity: .95; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--angle)) scale(.35); }
}
@keyframes firework-glow {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.16); }
  16% { opacity: .62; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.65); }
}
.share-panel p { margin-block: 9px 14px; color: var(--muted); }
.share-panel .hint { margin-bottom: 0; }
.share-url { margin-top: 9px; min-height: 35px; font-size: .79rem; }

.notice, .loading { max-width: 560px; margin: 0 auto 16px; text-align: center; color: var(--muted); }
dialog { width: min(440px, calc(100% - 32px)); background: var(--panel); color: var(--ink); border: 1px solid var(--border); border-radius: 16px; padding: 24px; }
dialog::backdrop { background: #181e2f70; }
dialog p { margin: 13px 0 20px; color: var(--muted); }
.finish-dialog {
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: clamp(12px, 4vw, 32px);
  border: 0;
  border-radius: 0;
  color: #f7f8ff;
  background: transparent;
  overflow: auto;
  overscroll-behavior: contain;
  color-scheme: dark;
}
.finish-dialog[open] { display: flex; flex-direction: column; }
body:has(.finish-dialog[open]) { overflow: hidden; }
.finish-dialog::backdrop { background: #080c20e8; backdrop-filter: blur(6px); }
.finish-card {
  position: relative;
  z-index: 1;
  flex: none;
  width: min(100%, 460px);
  margin: auto;
  padding: clamp(17px, 4vw, 32px);
  text-align: center;
  border: 1px solid #7986d8a6;
  border-radius: 25px;
  background: radial-gradient(ellipse at 50% 0%, #354077 0%, #1b2347 38%, #11182e 78%);
  box-shadow: 0 0 68px #5b70ff40, 0 22px 80px #0007;
}
.finish-dialog[open] .finish-card { animation: finish-arrive 420ms cubic-bezier(.18, .82, .28, 1.11) both; }
.finish-emblem {
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  margin: 0 auto 13px;
  border: 1px solid #ffdc8799;
  border-radius: 20px;
  color: #ffe197;
  background: linear-gradient(145deg, #98703b80, #473c5b99);
  box-shadow: 0 0 34px #ffbf4c50;
}
.finish-dialog[data-outcome="lost"] .finish-emblem {
  color: #ced8ff;
  border-color: #aab8ff66;
  background: #52619855;
  box-shadow: 0 0 28px #95a8ff33;
}
.finish-card h2 { margin: 0; font-size: clamp(1.8rem, 6vw, 2.75rem); line-height: 1.08; }
.finish-card h2:focus { outline: none; }
.finish-card .result-word { margin: 12px 0 0; color: #dce2ff; }
.finish-card .result-word bdi { color: #fff0bb; font-size: 1.24em; }
.finish-card .time-summary div { border-color: #7281c45c; background: #0d153b90; }
.finish-card .time-summary dt, .finish-card .hint { color: #c2cdee; }
.finish-card .hint { margin: 10px 0 0; }
.finish-card #refresh-times { color: #e7ebff; border-color: #8290c5; }
.finish-card #refresh-times:hover { background: #5869a64a; }
.finish-card .create-own {
  position: relative;
  width: 100%;
  min-height: 67px;
  margin-top: 17px;
  padding: 11px 15px;
  overflow: hidden;
  border: 1px solid #fff1b1;
  border-radius: 14px;
  color: #251b14;
  background: linear-gradient(112deg, #ffb83f, #fff1a2 46%, #ffd05d 72%, #ffa83e);
  box-shadow: 0 0 27px #ffc14b72, inset 0 1px 1px #fff9d6;
}
.finish-card .create-own strong { font-size: 1.2rem; }
.finish-card .create-own:hover { filter: brightness(1.09); }
.finish-card .create-own::after {
  content: '';
  position: absolute;
  inset: -60% auto -60% -42%;
  width: 28%;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, #fff9, transparent);
  animation: button-shine 1600ms 220ms ease-in-out 2 both;
}
.finish-dismiss { margin-top: 9px; min-height: 44px; color: #ccd7fa; background: transparent; }
.finish-dismiss:hover { color: #fff; background: #667ad02e; }
@keyframes finish-arrive {
  from { opacity: 0; transform: translateY(18px) scale(.88); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes button-shine {
  0%, 15% { transform: translateX(0) skewX(-23deg); }
  64%, 100% { transform: translateX(550%) skewX(-23deg); }
}
.dialog-actions { display: flex; gap: 8px; flex-wrap: wrap; }
footer { max-width: 1240px; margin-inline: auto; padding: 10px clamp(16px, 4vw, 50px) 24px; }
footer a { color: #213bae; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 760px), (pointer: coarse) {
  .phone-keyboard { display: inline-block; }
}
@media (max-width: 760px) {
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 23px; }
  main { padding-top: 25px; max-width: 490px; }
  .topbar { min-height: 64px; padding-block: 9px; }
  .wordmark { gap: 7px; }
  .wordmark i { width: 10px; height: 10px; }
  nav { gap: 6px; }
  nav .button { padding-inline: 9px; min-height: 38px; font-size: .83rem; }
  .setup-intro { text-align: center; }
  .setup-intro h1 br { display: none; }
  .setup-intro .subtitle { margin-inline: auto; }
  .sample-board { display: none; }
  .board { --cell: 47px; --gap: 5px; margin-top: 17px; }
  .tile { border-radius: 6px; font-size: clamp(14px, 5vw, 27px); }
  .game-status { margin-top: 9px; }
  .legend { margin-top: 8px; gap: 12px; }
  .side { gap: 12px; }
  .key-row { gap: 4px; }
}
@media (max-width: 360px) {
  .wordmark span { display: none; }
  .topbar { padding-inline: 13px; gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .fireworks { display: none; }
  .finish-dialog[open] .finish-card, .finish-card .create-own::after { animation: none; }
}
