:root {
  color-scheme: light;
  --ink: #1d2930;
  --muted: #60717a;
  --paper: #fffaf0;
  --panel: #ffffff;
  --line: #d8e0df;
  --tile: #fdfdfb;
  --tile-found: #f3c969;
  --tile-text: #24343b;
  --brand: #166b65;
  --brand-dark: #0e4845;
  --mint: #76c7b7;
  --coral: #e66f51;
  --gold: #e7ad35;
  --blue: #315f9c;
  --shadow: 0 18px 50px rgba(25, 42, 48, 0.18);
  --soft-shadow: 0 10px 28px rgba(25, 42, 48, 0.11);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at 20% 12%, rgba(118, 199, 183, 0.38), transparent 28rem),
    radial-gradient(circle at 92% 6%, rgba(230, 111, 81, 0.18), transparent 20rem),
    linear-gradient(160deg, #fffaf0 0%, #edf7f2 52%, #f9eee3 100%);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.54;
}

.app-shell {
  width: min(100%, 30rem);
  min-height: 100vh;
  margin: 0 auto;
  padding: 1rem;
  position: relative;
}

.screen {
  display: none;
  min-height: calc(100vh - 2rem);
  animation: screenIn 260ms ease;
}

.screen-active {
  display: flex;
  flex-direction: column;
}

.home-screen {
  justify-content: center;
  gap: 1rem;
  padding: 1rem 0 2rem;
}

.brand-mark {
  width: 4.25rem;
  height: 4.25rem;
  display: grid;
  place-items: center;
  border-radius: 1.2rem;
  background: linear-gradient(145deg, var(--brand), #229e8f);
  color: white;
  font-size: 2rem;
  font-weight: 900;
  box-shadow: var(--soft-shadow);
}

.eyebrow {
  margin: 0;
  color: var(--coral);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(3rem, 18vw, 4.8rem);
  line-height: 0.88;
}

h2 {
  font-size: 1.55rem;
  line-height: 1.05;
}

.home-copy {
  width: min(100%, 24rem);
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.45;
}

.difficulty-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.difficulty-card {
  min-height: 5rem;
  padding: 0.9rem;
  border: 1px solid rgba(29, 41, 48, 0.08);
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 8px 24px rgba(30, 60, 63, 0.06);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.difficulty-card span,
.difficulty-card small {
  display: block;
}

.difficulty-card span {
  font-weight: 900;
}

.difficulty-card small {
  margin-top: 0.35rem;
  color: var(--muted);
}

.difficulty-card.selected {
  border-color: rgba(22, 107, 101, 0.55);
  background: #ecfbf6;
  box-shadow: 0 0 0 3px rgba(22, 107, 101, 0.1);
}

.home-actions,
.modal-actions {
  display: grid;
  gap: 0.7rem;
}

.primary-action,
.secondary-action,
.ghost-action,
.danger-action {
  min-height: 3.2rem;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  font-weight: 900;
}

.primary-action {
  background: var(--brand);
  color: white;
  box-shadow: var(--soft-shadow);
}

.secondary-action {
  background: #eaf1ef;
  color: var(--brand-dark);
}

.ghost-action {
  background: transparent;
  color: var(--brand-dark);
  border: 1px solid rgba(22, 107, 101, 0.22);
}

.danger-action {
  background: #feece7;
  color: #a33822;
}

.screen-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1rem;
  padding-top: 0.5rem;
}

.icon-button {
  width: 2.7rem;
  height: 2.7rem;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 900;
  box-shadow: 0 6px 20px rgba(30, 60, 63, 0.08);
}

.custom-screen {
  padding-bottom: 1.5rem;
}

.custom-form {
  display: grid;
  gap: 0.85rem;
  padding: 0.85rem;
  border-radius: 0.65rem;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--soft-shadow);
}

.custom-form label,
.settings-modal label {
  display: grid;
  gap: 0.45rem;
}

.custom-form label {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.custom-form label > span {
  color: var(--ink);
  font-weight: 800;
}

.custom-form input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--brand);
}

.custom-form input[type="number"] {
  width: 6rem;
  min-height: 2.5rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: white;
  color: var(--ink);
  font-weight: 800;
}

output {
  color: var(--brand-dark);
  font-weight: 900;
}

.toggle-row {
  display: flex !important;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  min-height: 3rem;
}

.toggle-row input {
  width: 3rem;
  height: 1.55rem;
  accent-color: var(--brand);
}

.game-screen {
  gap: 0.7rem;
  padding-bottom: 1rem;
}

.top-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 0.4rem;
  align-items: center;
  padding-top: 0.1rem;
}

.top-bar > div {
  min-width: 0;
  min-height: 3rem;
  display: grid;
  align-content: center;
  padding: 0.42rem;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 5px 18px rgba(30, 60, 63, 0.06);
}

.stat-label {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
}

.top-bar strong {
  overflow: hidden;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 2rem;
}

.game-status h2 {
  font-size: 1rem;
}

.timer-pill {
  min-width: 4.5rem;
  padding: 0.42rem 0.65rem;
  border-radius: 999px;
  background: #fff3dd;
  color: #8a5410;
  font-weight: 900;
  text-align: center;
}

.board {
  --cols: 7;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: clamp(0.22rem, 1.2vw, 0.35rem);
  width: 100%;
  max-width: 27rem;
  margin: 0 auto;
  padding: 0.6rem;
  border-radius: 0.7rem;
  background: rgba(255, 255, 255, 0.54);
  box-shadow: inset 0 0 0 1px rgba(22, 107, 101, 0.08), var(--soft-shadow);
}

.board-cell {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 0.43rem;
  background: var(--tile);
  color: var(--tile-text);
  font-size: clamp(0.85rem, 5vw, 1.25rem);
  font-weight: 950;
  text-transform: uppercase;
  box-shadow: inset 0 -0.22rem 0 rgba(25, 42, 48, 0.08), 0 2px 8px rgba(25, 42, 48, 0.08);
  transition: transform 180ms ease, background 180ms ease;
}

.board-cell.empty {
  visibility: hidden;
}

.board-cell.revealed {
  background: linear-gradient(145deg, #ffe7a2, var(--tile-found));
  animation: tilePop 260ms ease;
}

.board-cell.hint-reveal {
  background: #c5f2e7;
}

.word-zone {
  min-height: 4.1rem;
  display: grid;
  align-content: end;
  gap: 0.4rem;
}

.feedback {
  min-height: 1.15rem;
  color: var(--coral);
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
}

.current-word {
  min-height: 2.2rem;
  display: grid;
  place-items: center;
  color: var(--brand-dark);
  font-size: 1.45rem;
  font-weight: 950;
  letter-spacing: 0.1rem;
  text-transform: uppercase;
}

.current-word.shake {
  animation: shake 260ms ease;
}

.wheel-panel {
  margin-top: auto;
  padding: 0.85rem;
  border-radius: 0.7rem;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: var(--shadow);
}

.letter-wheel {
  position: relative;
  width: min(72vw, 18rem);
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle, #ffffff 0 24%, rgba(22, 107, 101, 0.08) 25% 42%, rgba(49, 95, 156, 0.08) 43% 100%),
    linear-gradient(145deg, #f7fffb, #ecf3f4);
  box-shadow: inset 0 0 0 1px rgba(22, 107, 101, 0.12), inset 0 -0.8rem 2rem rgba(49, 95, 156, 0.08);
  touch-action: none;
  user-select: none;
}

.letter-wheel::after {
  content: "";
  position: absolute;
  inset: 39%;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: inset 0 -0.35rem 0 rgba(0, 0, 0, 0.12);
}

.letter-button {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3.5rem;
  height: 3.5rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #ffffff;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 950;
  box-shadow: 0 0.5rem 1.25rem rgba(25, 42, 48, 0.14), inset 0 -0.22rem 0 rgba(25, 42, 48, 0.08);
  transform: translate(-50%, -50%);
  transition: background 120ms ease, color 120ms ease, transform 120ms ease;
  z-index: 2;
}

.letter-button.selected {
  background: var(--brand);
  color: white;
}

.wheel-actions,
.power-bar {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.75rem;
}

.wheel-actions {
  grid-template-columns: 1fr 0.8fr 1fr;
}

.tool-button,
.power-button,
.bonus-meter {
  min-height: 2.75rem;
  padding: 0.55rem 0.65rem;
  border-radius: 0.5rem;
  background: #edf4f2;
  color: var(--brand-dark);
  font-weight: 900;
}

.tool-button span {
  font-size: 1.05rem;
}

.primary-tool {
  background: var(--brand);
  color: white;
}

.power-bar {
  grid-template-columns: 1fr 1fr 1fr;
}

.power-button,
.bonus-meter {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.1rem;
}

.power-button strong,
.bonus-meter strong {
  color: var(--coral);
  font-size: 0.95rem;
}

.bonus-meter {
  background: #fff5df;
  color: #7a4a0f;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 29, 32, 0.42);
  backdrop-filter: blur(7px);
  z-index: 20;
}

.modal {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(calc(100% - 2rem), 25rem);
  display: grid;
  gap: 1rem;
  padding: 1rem;
  border-radius: 0.75rem;
  background: var(--panel);
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%);
  z-index: 30;
  animation: modalIn 220ms ease;
}

.modal h2 {
  text-align: center;
}

.modal-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.modal-stats div {
  display: grid;
  gap: 0.2rem;
  padding: 0.75rem;
  border-radius: 0.5rem;
  background: #f3f8f6;
  text-align: center;
}

.modal-stats span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.modal-stats strong {
  font-size: 1.35rem;
}

.hidden {
  display: none !important;
}

@keyframes screenIn {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 0.7rem));
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

@keyframes tilePop {
  0% {
    transform: scale(0.84);
  }
  70% {
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-0.45rem);
  }
  50% {
    transform: translateX(0.45rem);
  }
  75% {
    transform: translateX(-0.25rem);
  }
}

@media (min-width: 48rem) {
  .app-shell {
    width: min(100%, 64rem);
    padding: 1.25rem;
  }

  .home-screen,
  .custom-screen {
    width: min(100%, 32rem);
    margin: 0 auto;
  }

  .game-screen {
    width: min(100%, 58rem);
    margin: 0 auto;
    display: none;
    grid-template-columns: minmax(0, 1fr) 20rem;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    align-items: start;
  }

  .game-screen.screen-active {
    display: grid;
  }

  .top-bar,
  .game-status,
  .board,
  .word-zone,
  .power-bar {
    grid-column: 1;
  }

  .wheel-panel {
    grid-column: 2;
    grid-row: 2 / span 3;
    position: sticky;
    top: 1.25rem;
  }

  .power-bar {
    max-width: 27rem;
    margin-left: auto;
    margin-right: auto;
  }
}
