  :root {
    color-scheme: dark;

    --bg: #07070b;
    --panel: rgba(255, 255, 255, 0.08);
    --ink: #ffffff;
    --muted: rgba(255, 255, 255, 0.68);
    --line: rgba(255, 255, 255, 0.16);
    --tile: rgba(255, 255, 255, 0.08);

    --green: #00e676;
    --yellow: #ffd400;
    --gray: #5b6070;
    --red: #ff5d6c;
    --blue: #ff7a3d;
    --pink: #ff4fb8;
    --orange: #ff7a3d;

    --app-height: 100dvh;
  }

  * {
    box-sizing: border-box;
  }

  html,
  body {
    margin: 0;
    height: 100%;
    overflow: hidden;
  }

  body {
    min-height: var(--app-height);
    font-family:
      Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
      sans-serif;
    background:
      radial-gradient(900px 520px at 15% 0%, rgba(255, 79, 184, 0.34), transparent 62%),
      radial-gradient(850px 560px at 90% 12%, rgba(255, 122, 61, 0.38), transparent 60%),
      radial-gradient(700px 500px at 50% 100%, rgba(255, 54, 97, 0.16), transparent 65%),
      #07070b;
    color: var(--ink);
  }

  button,
  input {
    font: inherit;
  }

  .app {
    height: var(--app-height);
    min-height: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    overflow: hidden;
  }

  .game {
    width: min(100%, 560px);
    max-height: calc(var(--app-height) - 48px);
    display: flex;
    flex-direction: column;
    background:
      linear-gradient(135deg, rgba(255, 79, 184, 0.16), rgba(255, 122, 61, 0.12)),
      rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 14px;
    padding: 22px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.46);
    backdrop-filter: blur(18px);
  }

  .topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
  }

  .brand-actions {
    display: grid;
    gap: 10px;
  }

  .brand-actions button {
    width: fit-content;
  }

  .topbar-actions {
    display: grid;
    gap: 8px;
    min-width: 118px;
  }

  h1 {
    margin: 0;
    font-size: 32px;
    line-height: 1.05;
    color: #fff;
  }

  p {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.4;
  }

  button {
    border: 0;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--pink), var(--orange));
    color: #fff;
    font-weight: 800;
    padding: 11px 14px;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 10px 24px rgba(255, 79, 184, 0.2);
  }

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

  .meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin: 22px 0 14px;
    color: var(--muted);
    font-weight: 700;
  }

  .board {
    display: grid;
    gap: 8px;
    flex: 1 1 auto;
    min-height: 0;
  }

  .row {
    display: grid;
    gap: 8px;
  }

  .tile {
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    min-width: 0;
    border: 2px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-weight: 900;
    font-size: clamp(18px, 8vw, 32px);
    text-transform: uppercase;
  }

  .tile.green,
  .tile.yellow,
  .tile.gray {
    border-color: transparent;
  }

  .tile.green {
    background: var(--green);
    color: #001f10;
    box-shadow: 0 0 18px rgba(0, 230, 118, 0.42);
  }

  .tile.yellow {
    background: var(--yellow);
    color: #261b00;
    box-shadow: 0 0 18px rgba(255, 212, 0, 0.42);
  }

  .tile.gray {
    background: var(--gray);
    color: #f2f5f8;
  }

  .tile.draft {
    border-color: var(--orange);
    background: rgba(255, 122, 61, 0.16);
    color: var(--ink);
  }

  .tile.hint {
    border-color: rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.28);
  }

  .letter-summary {
    display: grid;
    flex: 0 0 auto;
    gap: 7px;
    margin-top: 18px;
  }

  .letter-row {
    display: flex;
    justify-content: center;
    gap: 6px;
  }

  .letter-key {
    width: 34px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.78);
    font-size: 15px;
    font-weight: 900;
    padding: 0;
    text-transform: uppercase;
    cursor: pointer;
    white-space: normal;
  }

  .letter-key.green,
  .letter-key.yellow,
  .letter-key.gray {
    border-color: transparent;
  }

  .letter-key.green {
    background: var(--green);
    color: #001f10;
    box-shadow: 0 0 12px rgba(0, 230, 118, 0.38);
  }

  .letter-key.yellow {
    background: var(--yellow);
    color: #261b00;
    box-shadow: 0 0 12px rgba(255, 212, 0, 0.38);
  }

  .letter-key.gray {
    background: #474c5a;
    color: rgba(255, 255, 255, 0.48);
  }

  .letter-actions {
    margin-top: 2px;
  }

  .action-key {
    width: 108px;
    background: rgba(255, 255, 255, 0.12);
    color: var(--ink);
    text-transform: none;
    box-shadow: none;
  }

  .enter-key {
    width: 132px;
    background: linear-gradient(135deg, var(--pink), var(--orange));
    color: #fff;
  }

  .guess-form {
    display: grid;
    flex: 0 0 auto;
    grid-template-columns: 1fr auto;
    gap: 10px;
    margin-top: 18px;
  }

  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  input {
    min-width: 0;
    border: 2px solid var(--line);
    border-radius: 8px;
    padding: 12px 13px;
    background: rgba(0, 0, 0, 0.28);
    color: var(--ink);
    font-size: 16px;
    text-transform: uppercase;
  }

  input:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(255, 122, 61, 0.2);
    outline: 0;
  }

  .error {
    color: var(--red);
  }

  .success {
    color: var(--green);
  }

  .modal {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(3, 7, 12, 0.78);
  }

  .modal[hidden] {
    display: none;
  }

  .modal-panel {
    width: min(100%, 460px);
    max-height: calc(var(--app-height) - 36px);
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 14px;
    background:
      linear-gradient(135deg, rgba(255, 79, 184, 0.14), rgba(255, 122, 61, 0.1)),
      #101018;
    padding: 20px;
    box-shadow: 0 24px 90px rgba(0, 0, 0, 0.6);
  }

  .modal-panel h2 {
    margin: 0;
    font-size: 24px;
    color: #fff;
  }

  .modal-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .stats-panel {
    width: min(100%, 560px);
  }

  .stats-panel h3 {
    margin: 20px 0 10px;
    color: #fff;
    font-size: 15px;
    text-transform: uppercase;
  }

  .players-list {
    display: grid;
    gap: 8px;
    margin: 18px 0;
  }

  .global-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 16px;
  }

  .global-stats span {
    display: grid;
    gap: 2px;
    min-width: 0;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.07);
    padding: 9px;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
  }

  .global-stats strong {
    color: var(--ink);
    font-size: 18px;
  }

  .player-button {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 5px;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.08);
    color: var(--ink);
    text-align: left;
    box-shadow: none;
  }

  .player-name,
  .player-button .player-name {
    display: block;
    color: var(--ink);
    font-size: 18px;
    font-weight: 900;
    line-height: 1.15;
    overflow-wrap: anywhere;
  }

  .player-button strong,
  .player-button small {
    color: rgba(255, 255, 255, 0.72);
  }

  .player-button small {
    grid-column: 1 / -1;
  }

  .ranking-list,
  .player-stats-list {
    display: grid;
    gap: 8px;
  }

  .ranking-row,
  .player-stat-row {
    display: grid;
    align-items: center;
    gap: 5px 8px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.07);
    padding: 10px;
  }

  .ranking-row {
    grid-template-columns: 48px 1fr auto;
  }

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

  .rank {
    color: var(--yellow);
    font-weight: 900;
  }

  .ranking-row span:last-child,
  .player-stat-row span {
    color: var(--muted);
    font-size: 13px;
  }

  .player-stat-row span {
    display: inline-block;
    margin-right: 8px;
  }

  .manage-player-row {
    grid-template-columns: 1fr auto;
  }

  .manage-player-row .player-name,
  .manage-player-row span {
    grid-column: 1;
  }

  .delete-player-button {
    grid-column: 2;
    grid-row: 1 / span 3;
    align-self: center;
    background: #742837;
    color: #ffe6ea;
    box-shadow: none;
  }

  .player-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    margin-top: 18px;
  }

  .modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
  }

  .secondary-button {
    background: rgba(255, 255, 255, 0.12);
    color: var(--ink);
    box-shadow: none;
  }

  .empty-state {
    margin: 0;
    padding: 12px;
    border: 1px dashed rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    text-align: center;
  }

  .confetti {
    position: fixed;
    top: -14px;
    z-index: 20;
    width: 9px;
    height: 15px;
    border-radius: 2px;
    pointer-events: none;
    animation: confetti-fall 1.9s ease-in forwards;
  }

  .loss-panel {
    display: grid;
    justify-items: center;
    text-align: center;
    animation: loss-pop 0.3s ease-out;
  }

  .loss-mark {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    margin-bottom: 12px;
    border-radius: 50%;
    background: var(--red);
    color: #240303;
    font-size: 42px;
    font-weight: 900;
    animation: loss-shake 0.55s ease-in-out;
  }

  .loss-panel p {
    margin-bottom: 18px;
  }

  @keyframes loss-pop {
    from {
      transform: scale(0.92);
      opacity: 0;
    }
  }

  @keyframes loss-shake {
    20%,
    60% {
      transform: translateX(-6px);
    }

    40%,
    80% {
      transform: translateX(6px);
    }
  }

  @keyframes confetti-fall {
    to {
      transform: translate3d(var(--fall-x), calc(var(--app-height) + 40px), 0)
        rotate(var(--rotate));
      opacity: 0;
    }
  }

  @media (max-width: 520px) {
    .app {
      padding: 8px;
      place-items: stretch;
    }

    .game {
      width: 100%;
      max-height: calc(var(--app-height) - 16px);
      padding: 12px;
    }

    .topbar {
      align-items: center;
    }

    .topbar-actions {
      gap: 6px;
      min-width: 96px;
    }

    .brand-actions {
      gap: 7px;
    }

    .brand-actions button {
      width: 100%;
    }

    h1 {
      font-size: 24px;
    }

    p {
      margin-top: 5px;
      font-size: 13px;
    }

    .topbar button {
      padding: 9px 10px;
      font-size: 13px;
    }

    .meta {
      margin: 12px 0 10px;
      font-size: 13px;
    }

    .board,
    .row {
      gap: 5px;
    }

    .tile {
      border-width: 1px;
      font-size: clamp(16px, 6vw, 24px);
      border-radius: 6px;
    }

    .guess-form {
      grid-template-columns: 1fr;
      gap: 8px;
      margin-top: 10px;
    }

    .guess-form button {
      width: 100%;
      padding: 10px;
    }

    input {
      padding: 10px 12px;
    }

    .modal {
      padding: 8px;
    }

    .modal-panel {
      padding: 14px;
    }

    .modal-heading {
      align-items: flex-start;
    }

    .player-form,
    .modal-actions {
      grid-template-columns: 1fr;
    }

    .global-stats {
      grid-template-columns: repeat(2, 1fr);
    }

    .modal-actions {
      display: grid;
    }

    .ranking-row,
    .player-stat-row {
      grid-template-columns: 1fr;
      gap: 4px;
    }

    .letter-summary {
      gap: 5px;
      margin-top: 10px;
    }

    .letter-row {
      gap: 3px;
    }

    .letter-key {
      width: min(8.7vw, 30px);
      height: 30px;
      font-size: 12px;
    }

    .action-key {
      width: 112px;
      height: 34px;
      font-size: 13px;
    }

    .enter-key {
      width: 132px;
    }
  }

  @media (max-height: 720px) {
    .game {
      padding: 10px;
    }

    .topbar {
      gap: 8px;
    }

    h1 {
      font-size: 22px;
    }

    p {
      display: none;
    }

    .meta {
      margin: 8px 0;
    }

    .board,
    .row {
      gap: 4px;
    }

    .letter-summary {
      margin-top: 8px;
    }

    .guess-form {
      margin-top: 8px;
    }
  }