:root {
  color-scheme: dark;
  --bg: #101317;
  --panel: #191d22;
  --panel-2: #222831;
  --ink: #f5f2e9;
  --muted: #a8b0ba;
  --line: #333b45;
  --gold: #f7c948;
  --green: #25c685;
  --red: #ee6464;
  --blue: #6ea7ff;
  --violet: #aa86ff;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 15% 5%, rgba(247, 201, 72, 0.18), transparent 28rem),
    linear-gradient(135deg, #101317 0%, #141a1e 48%, #111317 100%);
  color: var(--ink);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button,
input,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
  cursor: pointer;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

.menu-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.menu-panel {
  width: min(980px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(25, 29, 34, 0.9);
  box-shadow: var(--shadow);
  padding: clamp(28px, 6vw, 58px);
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 30px;
}

.mode-card {
  display: grid;
  gap: 18px;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--ink);
  padding: 18px;
  text-decoration: none;
}

.mode-card:hover,
.mode-card:focus {
  border-color: var(--gold);
  outline: none;
}

.mode-card.disabled {
  pointer-events: none;
  opacity: 0.45;
}

.mode-card strong {
  font-size: 1.35rem;
}

.mode-card span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  line-height: 1.4;
}

.menu-mode {
  min-height: 280px;
}

.difficulty-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.difficulty-link,
.custom-play {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.difficulty-link:hover,
.difficulty-link:focus,
.difficulty-link.active,
.custom-play:hover,
.custom-play:focus {
  border-color: var(--gold);
  outline: none;
}

.difficulty-link.active,
.custom-play {
  background: rgba(247, 201, 72, 0.12);
}

.difficulty-link[data-difficulty="custom"] {
  grid-column: 1 / -1;
}

.menu-controls {
  display: grid;
  gap: 14px;
  margin-top: 30px;
}

.difficulty-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.difficulty-button {
  display: grid;
  gap: 7px;
  min-height: 110px;
  align-content: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--ink);
  padding: 14px;
  text-align: left;
}

.difficulty-button:hover,
.difficulty-button:focus,
.difficulty-button.active {
  border-color: var(--gold);
  outline: none;
}

.difficulty-button.active {
  background: rgba(247, 201, 72, 0.12);
}

.difficulty-button strong {
  font-size: 1.05rem;
}

.difficulty-button span {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.custom-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  padding: 14px;
}

.custom-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.custom-actions {
  display: flex;
  gap: 8px;
}

.custom-actions button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  padding: 7px 10px;
}

.custom-provider-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
}

.custom-play {
  margin-top: 12px;
}

.custom-play.disabled {
  pointer-events: none;
  opacity: 0.45;
}

.custom-provider {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  padding: 8px 10px;
  font-size: 0.86rem;
}

.custom-provider input {
  width: 16px;
  height: 16px;
  accent-color: var(--gold);
  flex: 0 0 auto;
}

.custom-provider span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-nav {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 14px;
}

.top-nav a {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  padding: 8px 12px;
  text-decoration: none;
}

.top-nav a:hover,
.top-nav a:focus {
  border-color: var(--gold);
  color: var(--ink);
  outline: none;
}

.hero {
  min-height: 380px;
}

.play,
.board,
.providers {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(25, 29, 34, 0.88);
  box-shadow: var(--shadow);
}

.play {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(24px, 4vw, 46px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(3rem, 8vw, 6.6rem);
  line-height: 0.92;
}

h2 {
  font-size: 1.18rem;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0 34px;
  color: var(--muted);
}

.stats span,
.provider-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  padding: 7px 11px;
  line-height: 1;
}

.stats strong {
  color: var(--ink);
}

.guess-form label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 700;
}

.combo {
  display: grid;
  grid-template-columns: 1fr 112px;
  gap: 10px;
}

input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11151a;
  color: var(--ink);
  outline: none;
  padding: 13px 14px;
}

input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(247, 201, 72, 0.18);
}

.combo button,
#newGameButton,
.share-button {
  border-radius: 8px;
  background: var(--gold);
  color: #16110a;
  font-weight: 900;
  padding: 0 16px;
}

.share-button {
  min-height: 42px;
  margin-top: 12px;
}

.slot-results {
  display: grid;
  gap: 7px;
  max-height: 230px;
  margin-top: 10px;
  overflow: auto;
  padding-right: 4px;
}

.search-meta {
  color: var(--muted);
  font-size: 0.82rem;
  padding: 4px 2px;
}

.slot-result {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--ink);
  padding: 10px 12px;
  text-align: left;
}

.slot-result:hover,
.slot-result:focus {
  border-color: var(--gold);
  outline: none;
}

.slot-result strong,
.slot-result span {
  min-width: 0;
}

.slot-result strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot-result span {
  color: var(--muted);
  font-size: 0.82rem;
}

.message {
  min-height: 48px;
  margin-top: 16px;
  color: var(--muted);
}

.message.win {
  color: var(--green);
}

.message.lose {
  color: var(--red);
}

.board,
.providers {
  margin-top: 24px;
}

.board-head,
.providers {
  padding: 18px;
}

.board-head,
.providers {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th,
td {
  border-top: 1px solid var(--line);
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
  font-size: 0.92rem;
}

th {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}

td {
  background: rgba(255, 255, 255, 0.02);
}

td.hit {
  background: rgba(37, 198, 133, 0.22);
  color: #dffced;
}

td.close {
  background: rgba(247, 201, 72, 0.18);
  color: #ffefb4;
}

td.miss {
  background: rgba(238, 100, 100, 0.13);
  color: #ffd4d4;
}

td small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.providers {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 320px);
}

.providers p {
  margin: 7px 0 0;
  color: var(--muted);
}

.provider-grid {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
}

.provider-pill {
  color: var(--muted);
  font-size: 0.86rem;
}

.provider-pill.miss {
  border-color: rgba(238, 100, 100, 0.55);
  background: rgba(238, 100, 100, 0.18);
  color: #ffd4d4;
}

.provider-pill.hit {
  border-color: rgba(37, 198, 133, 0.62);
  background: rgba(37, 198, 133, 0.2);
  color: #dffced;
}

@media (max-width: 820px) {
  .shell {
    width: min(100% - 20px, 680px);
    padding-top: 14px;
  }

  .mode-grid,
  .difficulty-grid,
  .combo,
  .providers {
    grid-template-columns: 1fr;
  }

  .combo button {
    min-height: 48px;
  }
}

/* Enhanced Mobile Responsiveness & Touch UX */
@media (max-width: 640px) {
  .shell {
    width: calc(100% - 16px);
    padding: 10px 0 28px;
  }

  .menu-panel {
    padding: 20px 16px;
    border-radius: 12px;
  }

  .eyebrow {
    font-size: 0.75rem;
    margin-bottom: 6px;
  }

  h1 {
    font-size: clamp(2.4rem, 11vw, 3.8rem);
  }

  .stats {
    gap: 6px;
    font-size: 0.82rem;
    margin: 14px 0 22px;
  }

  .stats span {
    padding: 6px 10px;
  }

  /* Prevent auto-zoom on iOS inputs */
  input,
  button,
  select,
  textarea {
    font-size: 16px;
  }

  .combo {
    grid-template-columns: 1fr auto;
    gap: 8px;
  }

  .combo input {
    padding: 12px;
  }

  .combo button {
    padding: 0 18px;
    min-height: 48px;
    font-size: 0.95rem;
    border-radius: 8px;
  }

  .top-nav {
    justify-content: space-between;
    width: 100%;
    margin-bottom: 12px;
    gap: 8px;
  }

  .top-nav a {
    flex: 1;
    text-align: center;
    padding: 10px 8px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
  }

  .difficulty-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .difficulty-link,
  .custom-play {
    min-height: 46px;
    font-size: 0.9rem;
  }

  .slot-results {
    max-height: 200px;
  }

  .slot-result {
    padding: 12px 14px;
    min-height: 48px;
  }

  .board-head,
  .providers {
    padding: 14px;
  }

  .board-head {
    flex-wrap: wrap;
    gap: 10px;
  }

  #newGameButton {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Sticky first column for mobile horizontal scrolling table */
  .table-wrap {
    margin: 0 -14px;
    padding: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 620px;
  }

  th,
  td {
    padding: 10px 8px;
    font-size: 0.84rem;
  }

  th:first-child,
  td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    box-shadow: 3px 0 6px rgba(0, 0, 0, 0.35);
  }

  th:first-child {
    background: #191d22;
  }

  td:first-child {
    background: #1c2026;
  }

  td.hit:first-child {
    background: #16402d;
  }

  td.close:first-child {
    background: #3d351b;
  }

  td.miss:first-child {
    background: #3d1f1f;
  }

  td small {
    font-size: 0.74rem;
  }

  .custom-provider-grid {
    grid-template-columns: 1fr;
    max-height: 220px;
  }

  .custom-provider {
    padding: 10px 12px;
    font-size: 0.9rem;
  }

  .custom-provider input {
    width: 20px;
    height: 20px;
  }

  .provider-grid {
    max-height: 200px;
  }

  .provider-pill {
    padding: 8px 12px;
    font-size: 0.84rem;
  }

  .share-button {
    width: 100%;
    min-height: 48px;
    font-size: 1rem;
  }
}

@media (max-width: 440px) {
  .difficulty-list {
    grid-template-columns: 1fr;
  }

  .difficulty-link[data-difficulty="custom"] {
    grid-column: 1;
  }

  .stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    text-align: center;
  }

  .stats span {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 0.75rem;
    padding: 8px 4px;
  }
}

