@font-face {
  font-family: "CMT Lora";
  font-style: normal;
  font-weight: 400;
  src: url("assets/fonts/lora-latin-ext-400-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+1E00-1E9F, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
  font-display: swap;
}

@font-face {
  font-family: "CMT Lora";
  font-style: normal;
  font-weight: 400;
  src: url("assets/fonts/lora-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  font-display: swap;
}

@font-face {
  font-family: "CMT Lora";
  font-style: normal;
  font-weight: 600;
  src: url("assets/fonts/lora-latin-ext-600-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+1E00-1E9F, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
  font-display: swap;
}

@font-face {
  font-family: "CMT Lora";
  font-style: normal;
  font-weight: 600;
  src: url("assets/fonts/lora-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  font-display: swap;
}

@font-face {
  font-family: "CMT Lora";
  font-style: normal;
  font-weight: 700;
  src: url("assets/fonts/lora-latin-ext-700-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+1E00-1E9F, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
  font-display: swap;
}

@font-face {
  font-family: "CMT Lora";
  font-style: normal;
  font-weight: 700;
  src: url("assets/fonts/lora-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  font-display: swap;
}

@font-face {
  font-family: "CMT Wedding Script";
  font-style: italic;
  font-weight: 400;
  src: url("assets/fonts/CMTWeddingScript-Regular.woff2") format("woff2");
  font-display: swap;
}

:root {
  --ink: #17372d;
  --ink-soft: #4d6258;
  --paper: #f4f4e8;
  --paper-deep: #dce4d3;
  --card: rgba(251, 250, 238, 0.91);
  --line: #a9bba8;
  --tile: #e6eadf;
  --tile-hover: #d7dfd1;
  --accent: #2f6654;
  --accent-dark: #20483c;
  --accent-deep: #173a31;
  --gold: #e8d78a;
  --focus: #a17b19;
  --success: #356648;
  --danger: #8c4238;
  --shadow: 0 22px 66px rgba(23, 55, 45, 0.16);
  color-scheme: light;
  font-family: "CMT Lora", Georgia, serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 300px;
  min-height: 100%;
  background: var(--accent-deep);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background: transparent;
}

.page-loading .knotwork-band {
  opacity: 0;
}

.page-loading .brand-mark.is-entering img,
.page-loading .site-header > div:last-child {
  opacity: 0;
  animation: none;
}

.knotwork-band {
  transition: opacity 450ms ease;
}

html::before {
  position: fixed;
  z-index: -1;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  width: 100lvw;
  height: 100lvh;
  background:
    linear-gradient(rgba(245, 247, 237, 0.12), rgba(245, 247, 237, 0.12)),
    url("assets/watercolour-background.png") center / cover no-repeat;
  content: "";
  pointer-events: none;
}

html::after {
  position: fixed;
  z-index: -1;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  width: 100lvw;
  height: 100lvh;
  background: linear-gradient(90deg, rgba(29, 71, 57, 0.07), transparent 22%, transparent 78%, rgba(29, 71, 57, 0.07));
  content: "";
  pointer-events: none;
}

@media (min-width: 38rem) {
  html::before {
    background-size: min(150vw, 88rem) auto;
    background-position: center top;
    background-repeat: repeat;
  }
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

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

[hidden] {
  display: none !important;
}

.knotwork-band {
  position: relative;
  z-index: 2;
  display: flex;
  width: 100%;
  height: clamp(3.25rem, 9.7vw, 6.2rem);
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: transparent;
  pointer-events: none;
}

.knotwork-track {
  position: absolute;
  top: 0;
  left: calc(50% - var(--border-track-initial-offset, 0px));
  display: flex;
  width: max-content;
  height: 100%;
  align-items: stretch;
  pointer-events: none;
  transform: translateX(var(--border-track-translate, 0px));
  will-change: transform;
}

.knotwork-band.is-hinting .knotwork-track {
  transition: transform 1.1s cubic-bezier(0.22, 0.72, 0.28, 1);
}

.knotwork-band img {
  display: block;
  width: auto;
  height: 100%;
  flex: 0 0 auto;
  max-width: none;
  object-fit: fill;
}

.knotwork-band-bottom {
  align-items: flex-end;
  transform: translateY(-0.35rem);
  cursor: default;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-touch-callout: none;
  transition: opacity 450ms ease;
}

.knotwork-band-top {
  transform: translateY(0.35rem);
  cursor: default;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-touch-callout: none;
  transition: opacity 450ms ease;
}

.knotwork-band-top .knotwork-track img {
  transform: rotate(180deg);
}

.knotwork-band-bottom.is-dragging {
  transition: none;
}

.knotwork-band-top.is-dragging,
.knotwork-band-top.is-coasting {
  transition: none;
}

.knotwork-band-bottom.is-coasting {
  transition: none;
}

.knotwork-band.is-locked {
  pointer-events: none;
}

.knotwork-band.is-endpoint-locked {
  pointer-events: none;
  cursor: default;
}

main {
  transition: height 550ms cubic-bezier(0.22, 0.72, 0.28, 1);
}

main.is-screen-transitioning {
  position: relative;
  overflow: hidden;
}

main.is-screen-transitioning > .welcome-card,
main.is-screen-transitioning > .game-screen {
  position: absolute;
  inset: 0;
  width: 100%;
  box-sizing: border-box;
  transition: opacity 420ms ease, transform 550ms cubic-bezier(0.22, 0.72, 0.28, 1);
}

main.is-screen-transitioning > .welcome-card {
  z-index: 1;
}

main.is-screen-transitioning > .game-screen {
  z-index: 2;
  pointer-events: none;
}

.screen-transition-leaving {
  opacity: 1;
  transform: translateY(0);
}

.screen-transition-entering {
  opacity: 0;
  transform: translateY(0.45rem);
}

.screen-transition-hidden {
  opacity: 0;
  transform: translateY(-0.35rem);
}

.screen-transition-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
  main,
  main.is-screen-transitioning > .welcome-card,
  main.is-screen-transitioning > .game-screen {
    transition-duration: 1ms;
  }
}

.page-shell {
  width: min(100%, 46rem);
  flex: 1 0 auto;
  margin: 0 auto;
  padding: 0.75rem max(0.85rem, env(safe-area-inset-right)) 1.1rem max(0.85rem, env(safe-area-inset-left));
}

.site-header {
  display: flex;
  align-items: center;
  gap: 2.1rem;
  margin: 0.00rem 0 2.0rem;
  transform: translateY(0.35rem);
}

.site-header > div:last-child {
  min-width: 0;
  overflow: visible;
}

@media (prefers-reduced-motion: no-preference) {
  .brand-mark.is-entering img {
    animation: wheel-roll-in 1.8s cubic-bezier(0.2, 0.8, 0.25, 1) both;
    transform-origin: center !important;
  }

  .site-header > div:last-child {
    animation: header-copy-reveal 0.65s ease-out 1.25s both;
  }
}

@keyframes wheel-roll-in {
  from {
    opacity: 0;
    transform: translateX(110vw) rotate(0deg);
  }
  to {
    opacity: 1;
    transform: translateX(0) rotate(-720deg);
  }
}

@keyframes header-copy-reveal {
  from {
    opacity: 0;
    transform: translateX(-0.5rem);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.brand-mark {
  display: grid;
  width: 3.2rem;
  height: 3.2rem;
  flex: 0 0 auto;
  overflow: visible;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: default;
  -webkit-touch-callout: none;
  touch-action: none;
  user-select: none;
}

.brand-mark img {
  display: block;
  position: relative;
  align-self: start;
  justify-self: start;
  width: 160%;
  height: 160%;
  top: -40%;
  object-fit: contain;
  transform-origin: top left;
}

@media (prefers-reduced-motion: no-preference) {
  .brand-mark.is-pressing img {
    animation: none;
    transform-origin: center !important;
  }

  .brand-mark.is-cooling img {
    transform-origin: center !important;
  }
}

@keyframes wheel-hold-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: no-preference) {
  .brand-mark.is-reward-spinning img {
    animation: wheel-reward-spin 1.2s cubic-bezier(0.22, 1, 0.36, 1) both;
    transform-origin: center;
  }
}

@keyframes wheel-reward-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.eyebrow,
.section-kicker {
  margin: 0 0 0.18rem;
  color: var(--accent);
  font-size: 0.69rem;
  font-weight: 760;
  letter-spacing: 0.13em;
  line-height: 1.2;
  text-transform: uppercase;
}

.wordmark {
  display: block;
  margin: 0;
  width: clamp(10.55rem, 50.5vw, 15.85rem);
  height: auto;
  max-width: 100%;
  transform: translateY(0.5rem) rotate(-1.5deg) scale(1.35);
  transform-origin: left center;
}

.welcome-card,
.game-screen {
  border: 1px solid rgba(47, 102, 84, 0.22);
  border-radius: 0.35rem;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(5px);
}

.welcome-card {
  position: relative;
  overflow: hidden;
  padding: clamp(1.65rem, 6vw, 3.7rem) clamp(1.2rem, 6vw, 3.5rem) 1rem;
}

.welcome-card h1 {
  width: 100%;
  max-width: none;
  margin: 0.2rem 0 1rem;
  color: var(--accent-deep);
  font-family: "CMT Wedding Script", cursive;
  font-style: italic;
  font-size: clamp(2.8rem, 13vw, 5rem);
  font-weight: 400;
  line-height: 0.83;
  white-space: pre;
}

.welcome-instructions {
  max-width: 34rem;
  margin: 0 0 1.6rem;
  color: var(--ink-soft);
}

.welcome-instructions h2 {
  margin: 0 0 0.55rem;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 760;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.welcome-instructions ul {
  margin: 0;
  padding-left: 0;
  list-style: none;
  font-size: 0.94rem;
  line-height: 1.5;
}

.welcome-instructions li {
  position: relative;
  padding-left: 1.15rem;
}

.welcome-instructions li::before {
  position: absolute;
  left: 0;
  color: var(--accent);
  content: "✦";
}

.welcome-instructions li + li {
  margin-top: 0.34rem;
}

.welcome-copy {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.65;
}

.team-form,
.word-form {
  display: grid;
  gap: 0.48rem;
}

.team-form label,
.word-form label {
  font-size: 0.83rem;
  font-weight: 700;
}

.input-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
}

input {
  width: 100%;
  min-width: 0;
  min-height: 3.15rem;
  border: 1.5px solid #8da495;
  border-radius: 0.35rem;
  background: rgba(255, 255, 246, 0.88);
  color: var(--ink);
  padding: 0.7rem 0.85rem;
  font-size: 1rem;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input:hover {
  border-color: var(--accent);
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 102, 84, 0.14);
}

input:disabled {
  border-color: #b7c2b8;
  background: rgba(222, 227, 218, 0.72);
  color: var(--ink-soft);
  cursor: not-allowed;
}

.button {
  min-height: 3.05rem;
  border: 1px solid transparent;
  border-radius: 0.35rem;
  padding: 0.7rem 1rem;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.15;
  cursor: pointer;
  transition: transform 120ms ease, background-color 150ms ease, border-color 150ms ease, opacity 150ms ease;
}

.button:not(:disabled):active {
  transform: translateY(1px) scale(0.99);
}

.button-primary {
  border-color: rgba(232, 215, 138, 0.35);
  background: var(--accent-dark);
  color: #fffdf0;
}

.button-primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.button-dark {
  background: var(--accent-deep);
  color: #fffdf0;
}

.button-dark:hover:not(:disabled) {
  background: #0f2c24;
}

.button-secondary {
  border-color: #879e8e;
  background: rgba(249, 249, 238, 0.38);
  color: var(--ink);
}

.button-secondary:hover:not(:disabled) {
  background: #e0e7da;
  border-color: var(--accent);
}

.button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.form-message {
  min-height: 1.25rem;
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 1.35;
}

.form-message[data-tone="error"] {
  color: var(--danger);
}

.form-message[data-tone="success"] {
  color: var(--success);
}

.welcome-note {
  display: flex;
  gap: 0.45rem;
  align-items: flex-start;
  margin: 1.5rem 0 0;
  color: var(--ink-soft);
  font-size: 0.8rem;
  line-height: 1.4;
}

.welcome-note span {
  color: var(--accent);
}

.game-screen {
  padding: clamp(1rem, 4vw, 2rem);
}

.game-heading-row,
.score-line {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.game-heading-row {
  align-items: flex-start;
  padding-block: 0.35rem 1.15rem;
}

.game-heading-row.has-long-team-name {
  /* Reserve room for the scaled, rotated heading once it wraps. */
  padding-bottom: 2.5rem;
}

.game-heading-row > div {
  min-width: 0;
  flex: 1 1 auto;
}

.team-heading {
  width: calc(100% / 1.4);
  max-width: 20ch;
  margin: 0.5rem 0 0;
  color: var(--accent-deep);
  font-family: "CMT Wedding Script", cursive;
  font-style: italic;
  font-size: clamp(2.55rem, 10.5vw, 3.9rem);
  font-weight: 400;
  line-height: 0.88;
  overflow-wrap: anywhere;
  word-break: normal;
  hyphens: auto;
  transform: translateY(0.5rem) rotate(-2deg) scale(1.4);
  transform-origin: left center;
}

.text-button {
  min-height: 2.75rem;
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  padding: 0.5rem;
  font-size: 0.81rem;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: rgba(32, 72, 60, 0.42);
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.text-button:hover {
  text-decoration-color: currentColor;
}

.text-button.muted {
  color: #5f7168;
  font-weight: 600;
}

.score-card {
  margin: 1.15rem 0 0.55rem;
  border: 1px solid rgba(47, 102, 84, 0.2);
  border-radius: 0.35rem;
  background: rgba(223, 233, 217, 0.66);
  padding: 0.8rem 0.9rem 0.72rem;
}

.score-line {
  margin-bottom: 0.48rem;
  font-size: 0.82rem;
  font-weight: 700;
}

.score-line strong {
  font-size: 1.12rem;
  font-variant-numeric: tabular-nums;
}

.score-track {
  display: block;
  width: 100%;
  height: 0.48rem;
  border: 0;
  overflow: hidden;
  border-radius: 999px;
  background: #c7d2c4;
  appearance: none;
}

.score-track::-webkit-progress-bar {
  border-radius: inherit;
  background: #c7d2c4;
}

.score-track::-webkit-progress-value {
  border-radius: inherit;
  background: linear-gradient(90deg, #1d4b3c, #5f8c6d);
  transition: width 380ms ease;
}

.score-track::-moz-progress-bar {
  border-radius: inherit;
  background: #2f6654;
}

.score-card.score-over-limit .score-track::-webkit-progress-value {
  background: linear-gradient(90deg, #a66b17, #e0b34f);
}

.score-card.score-over-limit .score-track::-moz-progress-bar {
  background: linear-gradient(90deg, #a66b17, #e0b34f);
}

.score-note {
  margin: 0.42rem 0 0;
  color: var(--ink-soft);
  font-size: 0.72rem;
  white-space: nowrap;
}

.score-card.score-hit {
  animation: score-hit 480ms ease;
}

.score-card.score-bonus {
  animation: score-bonus 700ms ease;
}

@keyframes score-hit {
  0%, 100% { border-color: rgba(47, 102, 84, 0.2); transform: translateX(0); }
  25% { border-color: rgba(154, 73, 62, 0.75); transform: translateX(-2px); }
  50% { transform: translateX(2px); }
  75% { transform: translateX(-1px); }
}

.board {
  display: grid;
  gap: 0.46rem;
}

.resolved-groups {
  display: grid;
  gap: 0.46rem;
}

.resolved-group {
  display: grid;
  min-height: 4.55rem;
  place-content: center;
  border: 1px solid rgba(54, 47, 45, 0.12);
  border-radius: 0.28rem;
  padding: 0.62rem 0.55rem;
  text-align: center;
}

.resolved-group.is-new {
  animation: group-in 360ms ease both;
}

.resolved-group h2 {
  margin: 0;
  font-size: clamp(0.78rem, 3.2vw, 0.98rem);
  letter-spacing: 0.015em;
  line-height: 1.2;
  text-transform: uppercase;
}

.resolved-group p {
  margin: 0.28rem 0 0;
  font-size: clamp(0.67rem, 2.8vw, 0.83rem);
  font-weight: 620;
  letter-spacing: 0.035em;
  line-height: 1.25;
}

@keyframes group-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.42rem;
}

.word-tile,
.blank-tile {
  width: 100%;
  min-width: 0;
  min-height: clamp(3.4rem, 16.5vw, 5.15rem);
  border-radius: 0.28rem;
}

.word-tile {
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  background: var(--tile);
  color: var(--ink);
  padding: 0.3rem 0.2rem;
  font-size: clamp(0.56rem, 2.8vw, 0.84rem);
  font-weight: 700;
  letter-spacing: -0.005em;
  line-height: 1.05;
  text-align: center;
  overflow-wrap: anywhere;
  cursor: pointer;
  user-select: none;
  -webkit-touch-callout: none;
  transition: transform 130ms ease, background-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.word-tile--photo {
  padding: 0;
  perspective: 44rem;
  overflow: hidden;
}

.word-tile--photo.is-shining::after {
  position: absolute;
  z-index: 3;
  top: -45%;
  left: -75%;
  width: 42%;
  height: 190%;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.72), transparent);
  pointer-events: none;
  transform: rotate(18deg);
  animation: photo-card-shine 850ms ease-out both;
}

@keyframes photo-card-shine {
  from { left: -75%; }
  to { left: 145%; }
}

.word-tile-inner {
  position: relative;
  display: block;
  width: 100%;
  min-height: inherit;
  transform-style: preserve-3d;
  transition: transform 520ms ease;
}

.word-tile-face {
  position: absolute;
  inset: 0;
  display: grid;
  min-height: inherit;
  place-items: center;
  padding: 0.3rem 0.2rem;
  border-radius: inherit;
  backface-visibility: hidden;
  overflow-wrap: anywhere;
}

.word-tile-front {
  background: var(--tile);
}

.word-tile-back {
  padding: 0;
  background: var(--tile);
  transform: rotateY(180deg);
}

.word-tile-back img {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.word-tile--photo.is-photo-revealed .word-tile-inner {
  transform: rotateY(180deg);
}

.word-tile--photo.is-photo-returning .word-tile-inner {
  animation: photo-flip-back 520ms ease both;
}

@keyframes photo-flip-back {
  from { transform: rotateY(180deg); }
  to { transform: rotateY(360deg); }
}

.word-tile:hover:not(:disabled):not([aria-pressed="true"]) {
  background: var(--tile-hover);
}

.word-tile--photo:hover:not(:disabled):not([aria-pressed="true"]) .word-tile-front {
  background: var(--tile-hover);
}

.word-tile[aria-pressed="true"] {
  border-color: #17372d;
  background: #52645a;
  color: #fffdf3;
  box-shadow: inset 0 0 0 1px rgba(232, 215, 138, 0.36);
}

.word-tile[aria-pressed="true"] .word-tile-front {
  background: #52645a;
  color: #fffdf3;
}

.word-tile:disabled {
  color: #4d5e55;
  cursor: default;
}

/* Long single words get a small reduction; phrases remain free to wrap. */
.word-tile.word-tile--long {
  font-size: clamp(0.52rem, 2.5vw, 0.76rem);
}

.word-tile.word-tile--very-long {
  font-size: clamp(0.49rem, 2.25vw, 0.7rem);
}

.blank-tile {
  display: grid;
  place-items: center;
  border: 1.5px dashed #a9b7aa;
  background: rgba(229, 235, 222, 0.48);
}

.blank-tile::before {
  width: 34%;
  height: 0.28rem;
  border-radius: 999px;
  background: #b8c5b7;
  content: "";
  opacity: 0.72;
}

.word-form {
  margin-top: 0.55rem;
}

/* Word feedback uses the fixed banner, so it should not reserve space here. */
.word-form > .form-message {
  display: none;
}

.game-actions {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.55rem;
}

.submit-button {
  width: 100%;
}

.secondary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.submission-status {
  min-height: 1rem;
  margin: 0.65rem 0 0;
  color: var(--ink-soft);
  font-size: 0.7rem;
  text-align: center;
}

.game-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.rem;
  margin-top: 0.1rem;
}

.map-dialog {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  box-sizing: border-box;
  width: 100vw;
  max-width: 100vw;
  max-height: none;
  place-items: center;
  overflow: auto;
  padding: 0.5rem;
  background: rgba(20, 49, 40, 0.66);
  backdrop-filter: blur(3px);
}

.map-dialog[hidden] {
  display: none;
}

.map-panel {
  box-sizing: border-box;
  width: fit-content;
  max-width: calc(100vw - 1rem);
  max-height: calc(100svh - 1rem);
  overflow: auto;
  border: 1px solid rgba(47, 102, 84, 0.32);
  border-radius: 0.4rem;
  background:
    linear-gradient(rgba(252, 251, 240, 0.9), rgba(252, 251, 240, 0.9)),
    url("assets/watercolour-background.png") center / cover;
  box-shadow: 0 24px 80px rgba(35, 29, 33, 0.28);
  padding: 1.4rem 1.1rem 1.2rem;
}

.map-panel h2 {
  margin: 0.2rem 0 0.9rem;
  color: var(--accent-deep);
  font-family: "CMT Wedding Script", cursive;
  font-size: clamp(2.25rem, 10vw, 3.8rem);
  font-style: italic;
  font-weight: 400;
  line-height: 0.9;
  text-align: center;
}

.map-image {
  display: block;
  position: static;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.map-image-frame {
  display: flex;
  width: 100%;
  height: min(calc(100svh - 12rem), 100vw);
  align-items: center;
  justify-content: center;
  place-items: center;
  overflow: hidden;
}

.word-reveal-panel {
  width: min(100%, 30rem);
}

.word-reveal-panel h2 {
  margin-bottom: 0.75rem;
}

.word-reveal-message {
  max-width: 25rem;
  margin: 0 auto 1.1rem;
  color: var(--ink-soft);
  line-height: 1.45;
  text-align: center;
}

.word-reveal-actions {
  display: grid;
  gap: 0.55rem;
}

.word-reveal-actions .button {
  width: 100%;
}

.result-separator {
  color: var(--ink-soft);
  font-size: 0.81rem;
}

.feedback-banner {
  position: fixed;
  z-index: 20;
  top: calc(var(--visual-viewport-top, 0px) + max(0.75rem, env(safe-area-inset-top)));
  left: var(--visual-viewport-centre, 50%);
  width: min(calc(var(--visual-viewport-width, 100vw) - 1.5rem), 34rem);
  border: 1px solid rgba(232, 215, 138, 0.54);
  border-radius: 0.3rem;
  background: var(--accent-deep);
  box-shadow: 0 10px 32px rgba(20, 52, 42, 0.24);
  color: #fffdf0;
  padding: 0.85rem 1.05rem;
  font-size: 0.9rem;
  font-weight: 780;
  text-align: center;
  transform: translate(-50%, -0.7rem);
  opacity: 0;
}

.feedback-banner[data-tone="success"] {
  background: #315d41;
}

.feedback-banner[data-tone="error"] {
  background: #77463f;
}

.feedback-banner.is-visible {
  animation: banner-in-out 3s ease both;
}

@keyframes banner-in-out {
  0% { opacity: 0; transform: translate(-50%, -0.7rem); }
  8%, 88% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -0.25rem); }
}

.completion-dialog {
  width: min(calc(100% - 1.5rem), 34rem);
  max-height: calc(100dvh - 1.5rem);
  overflow: auto;
  border: 1px solid rgba(47, 102, 84, 0.32);
  border-radius: 0.4rem;
  background:
    linear-gradient(rgba(252, 251, 240, 0.9), rgba(252, 251, 240, 0.9)),
    url("assets/watercolour-background.png") center / cover;
  color: var(--ink);
  padding: 0;
  box-shadow: 0 24px 80px rgba(35, 29, 33, 0.28);
}

.completion-dialog::backdrop {
  background: rgba(20, 49, 40, 0.66);
  backdrop-filter: blur(3px);
}

.completion-panel {
  position: relative;
  padding: 1.65rem 1.2rem 1.35rem;
  text-align: center;
}

.dialog-close {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--accent-dark);
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
}

.dialog-close:hover {
  background: #e3eadf;
}

.completion-panel h2 {
  margin: 0.35rem 0 0.8rem;
  color: var(--accent-deep);
  font-family: "CMT Wedding Script", cursive;
  font-style: italic;
  font-size: clamp(3.15rem, 15vw, 4.8rem);
  font-weight: 400;
  line-height: 0.85;
}

.final-score-wrap {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 0.4rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.final-score {
  color: var(--ink);
  font-family: "CMT Lora", Georgia, serif;
  font-size: 3.2rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.05em;
  line-height: 1;
}

.ranking-label {
  margin: 0.65rem auto 1.35rem;
  color: var(--accent-dark);
  font-family: "CMT Lora", Georgia, serif;
  font-size: 1.25rem;
  font-style: italic;
}

.result-section {
  margin-top: 0.72rem;
  border: 1px solid #becbbc;
  border-radius: 0.3rem;
  background: rgba(246, 248, 237, 0.72);
  padding: 0.82rem;
}

.result-section h3 {
  margin: 0 0 0.55rem;
  color: var(--ink-soft);
  font-size: 0.69rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.solve-order {
  margin: 0;
  font-size: 1.42rem;
  letter-spacing: 0.15em;
}

.guess-history {
  display: grid;
  gap: 0.16rem;
  justify-content: center;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  font-size: 1.25rem;
  line-height: 1.18;
  letter-spacing: 0.045em;
}

.bonus-dialog {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  box-sizing: border-box;
  width: 100vw;
  max-width: 100vw;
  max-height: none;
  place-items: center;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.5rem;
  background: rgba(20, 49, 40, 0.66);
  backdrop-filter: blur(3px);
}

.bonus-dialog[hidden] {
  display: none;
}

.bonus-panel {
  box-sizing: border-box;
  width: min(100%, 34rem);
  min-width: 0;
  max-width: 100%;
  max-height: calc(100svh - 1rem);
  overflow: auto;
  border: 1px solid rgba(47, 102, 84, 0.32);
  border-radius: 0.4rem;
  background:
    linear-gradient(rgba(252, 251, 240, 0.9), rgba(252, 251, 240, 0.9)),
    url("assets/watercolour-background.png") center / cover;
  box-shadow: 0 24px 80px rgba(35, 29, 33, 0.28);
  padding: 1.15rem 0.85rem 0.95rem;
}

.bonus-panel h2 {
  margin-top: 0.2rem;
  margin-bottom: 0.55rem;
  font-size: clamp(2.45rem, 12vw, 4rem);
}

.bonus-instructions {
  overflow-wrap: anywhere;
  white-space: pre-line;
  margin: 0 auto 0.8rem;
  max-width: 24rem;
  color: var(--ink-soft);
}

.bonus-lives {
  margin: 0;
  color: #2f6654;
  font-size: 1.45rem;
  letter-spacing: 0.2em;
  line-height: 1;
}

.bonus-status {
  display: flex;
  min-height: 2.8rem;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  margin: 0.7rem 0 0;
}

.bonus-lives {
  order: 1;
}

.bonus-hint {
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-style: italic;
  order: 2;
  text-align: center;
}

.bonus-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.42rem;
  margin: 0 auto 0.9rem;
  max-width: 25rem;
}

.bonus-surname {
  min-width: 0;
  min-height: clamp(2.65rem, 11vw, 3.2rem);
  padding: 0.4rem;
  border: 1px solid #becbbc;
  border-radius: 0.28rem;
  background: rgba(246, 248, 237, 0.72);
  color: var(--ink);
  font-size: clamp(0.72rem, 3.2vw, 0.95rem);
  font-weight: 700;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.bonus-surname.is-selected {
  border-color: var(--accent-dark);
  background: #c6d8b9;
  box-shadow: inset 0 0 0 2px rgba(47, 102, 84, 0.18);
}

.guess-history p {
  margin: 0;
  white-space: nowrap;
}

.copy-button {
  width: 100%;
  margin-top: 1rem;
}

.copy-status {
  min-height: 1.15rem;
  margin: 0.5rem 0 0;
  color: var(--success);
  font-size: 0.78rem;
}

.fatal-error {
  width: min(calc(100% - 2rem), 40rem);
  margin: 3rem auto;
  border: 1px solid #d8afa9;
  border-radius: 0.8rem;
  background: #fff4f1;
  color: #743b34;
  padding: 1rem;
  line-height: 1.5;
}

@media (min-width: 38rem) {
  .page-shell {
    padding-top: 0.75rem;
  }

  .game-screen {
    padding: 1.65rem;
  }

  .word-grid {
    gap: 0.5rem;
  }

  .resolved-groups,
  .board {
    gap: 0.5rem;
  }

  .word-tile,
  .blank-tile {
    min-height: 5.15rem;
  }

  .game-actions {
    grid-template-columns: minmax(12rem, 1.25fr) 1fr;
  }

  .secondary-actions {
    grid-column: 2;
  }

  .completion-panel {
    padding: 2rem 2rem 1.5rem;
  }
}

@keyframes score-bonus {
  0%, 100% { transform: rotate(0deg); }
  18% { transform: rotate(-1.2deg) translateX(-1px); }
  36% { transform: rotate(1deg) translateX(1px); }
  54% { transform: rotate(-0.65deg); }
  72% { transform: rotate(0.35deg); }
}

@media (max-width: 22rem) {
  .page-shell {
    padding-inline: 0.55rem;
  }

  .game-screen {
    padding-inline: 0.65rem;
  }

  .word-grid {
    gap: 0.28rem;
  }

  .word-tile,
  .blank-tile {
    min-height: 3.15rem;
    border-radius: 0.45rem;
  }

  .word-tile {
    font-size: 0.53rem;
  }

  .resolved-group {
    border-radius: 0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
