:root {
  --ink: #181713;
  --panel: #fff3d7;
  --panel-soft: #f7e8c0;
  --paper: #fffaf0;
  --field: #e8efe4;
  --line: #2a2923;
  --muted: #6f6a5b;
  --green: #16856d;
  --green-dark: #0e5f51;
  --gold: #d6a934;
  --red: #bd4b3a;
  --white: #fffdf6;
  --shadow: 0 22px 0 rgba(24, 23, 19, 0.1), 0 30px 52px rgba(24, 23, 19, 0.18);
  color: var(--ink);
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", ui-rounded, sans-serif;
  background: #e4ebe4;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    linear-gradient(90deg, rgba(24, 23, 19, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(24, 23, 19, 0.03) 1px, transparent 1px),
    linear-gradient(180deg, #f4f1e5, #dfe9df);
  background-size: 22px 22px, 22px 22px, auto;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.02;
  letter-spacing: 0;
}

h3 {
  margin: 0 0 8px;
  font-size: 22px;
  line-height: 1.1;
}

.mobile-shell {
  width: min(100%, 430px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 10px calc(92px + env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(255, 250, 240, 0.62), rgba(232, 239, 228, 0.92)),
    var(--field);
}

.game-card,
.debug-panel {
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.game-card {
  min-height: calc(100svh - 112px - env(safe-area-inset-top));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.game-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(24, 23, 19, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(24, 23, 19, 0.035) 1px, transparent 1px);
  background-size: 18px 18px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.85), transparent 48%);
}

.round-summary,
.guess-panel,
.settlement-panel {
  position: relative;
}

.round-summary {
  padding: 14px;
  border-bottom: 2px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 253, 246, 0.82), rgba(247, 232, 192, 0.76)),
    var(--panel-soft);
}

.round-strip,
.card-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.round-strip {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin: 10px 0 0;
}

.card-title-row {
  justify-content: space-between;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.category-tag,
.length-tag,
.online-badge,
.subtle-pill {
  min-height: 27px;
  display: inline-flex;
  align-items: center;
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 2px 0 rgba(24, 23, 19, 0.16);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.category-tag {
  background: #dff3d4;
  color: var(--green-dark);
}

.length-tag {
  background: #fff2bd;
}

.online-badge {
  background: #e8f2f0;
}

.online-badge b {
  margin-right: 4px;
}

.subtle-pill {
  border-color: #cbc0a2;
  background: #fff8df;
  color: var(--muted);
  box-shadow: none;
}

.hint-box {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  min-height: 60px;
  border: 2px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--white);
}

.hint-box span {
  height: 100%;
  display: grid;
  place-items: center;
  background: var(--green-dark);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.hint-box p {
  margin: 0;
  padding: 10px 12px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
}

.settlement-panel {
  margin: 12px 14px 0;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff2bd;
}

.settlement-panel p {
  margin-bottom: 10px;
  color: var(--muted);
  line-height: 1.35;
}

.settlement-ranking,
.guess-feed {
  list-style: none;
  margin: 0;
  padding: 0;
}

.settlement-ranking {
  display: grid;
  gap: 7px;
}

.settlement-ranking li {
  min-height: 34px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 0 10px;
  border: 1px solid rgba(24, 23, 19, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.64);
  font-size: 13px;
}

.settlement-ranking strong {
  text-transform: uppercase;
}

.settlement-ranking em {
  color: var(--green-dark);
  font-style: normal;
  font-weight: 900;
}

.guess-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 14px;
  background: linear-gradient(180deg, rgba(255, 253, 246, 0.68), rgba(255, 250, 240, 0.92));
}

.guess-table-head,
.guess-row {
  display: grid;
  grid-template-columns: minmax(88px, 0.86fr) minmax(0, 1fr);
  gap: 7px;
  align-items: center;
}

.guess-table-head {
  margin: 10px 0 7px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.guess-feed {
  flex: 1;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.guess-feed::-webkit-scrollbar {
  display: none;
}

.guess-feed:has(.empty-state) {
  grid-template-rows: 1fr;
  align-content: stretch;
}

.guess-row {
  --score: 0%;
  --score-color: #eadcc4;
  min-height: 56px;
  position: relative;
  padding: 8px;
  border: 2px solid rgba(24, 23, 19, 0.18);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 3px 0 rgba(24, 23, 19, 0.08);
  overflow: hidden;
}

.guess-row::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--score);
  background: var(--score-color);
  transition: width 180ms ease;
}

.guess-row.mine {
  border-color: var(--green);
  background: #f4fff0;
}

.guess-row.correct {
  border-color: var(--gold);
  background: #fff0b8;
}

.player-cell,
.word-cell {
  position: relative;
  z-index: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-cell {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.word-cell {
  color: var(--ink);
  font-size: 17px;
  font-weight: 900;
  text-transform: uppercase;
}

.empty-state {
  height: 100%;
  min-height: 100%;
  display: grid;
  place-items: center;
  border: 2px dashed rgba(24, 23, 19, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(24, 23, 19, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(24, 23, 19, 0.035) 1px, transparent 1px),
    rgba(255, 253, 246, 0.58);
  background-size: 18px 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.guess-form {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  width: min(100%, 430px);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px;
  gap: 8px;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  border-top: 2px solid var(--line);
  background: rgba(255, 250, 240, 0.96);
  box-shadow: 0 -10px 0 rgba(24, 23, 19, 0.08);
  backdrop-filter: blur(12px);
}

.guess-form input,
.guess-form button {
  height: 50px;
  border-radius: 8px;
  font-weight: 900;
}

.guess-form input {
  width: 100%;
  border: 2px solid var(--line);
  background: var(--white);
  color: var(--ink);
  outline: none;
  padding: 0 13px;
  font-size: 16px;
}

.guess-form input:focus {
  box-shadow: 0 0 0 3px rgba(22, 133, 109, 0.18);
}

.guess-form button {
  border: 2px solid var(--line);
  background: var(--green);
  color: #fff;
  box-shadow: 0 4px 0 var(--green-dark);
}

.guess-form button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--green-dark);
}

.form-status {
  display: none;
  grid-column: 1 / -1;
  margin: 0 2px -2px;
  color: var(--red);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.3;
}

.form-status:not(:empty) {
  display: block;
}

.guess-form input:disabled,
.guess-form button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.debug-panel {
  margin-top: 12px;
  padding: 14px;
  display: grid;
  gap: 4px;
  background: #202821;
  color: #fff;
}

.debug-panel span {
  color: #b6c2b9;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.debug-panel strong {
  font-size: 18px;
}

@media (min-width: 431px) {
  body {
    padding: 18px 0;
  }

  .mobile-shell {
    min-height: calc(100svh - 36px);
    border-radius: 28px;
    box-shadow: 0 28px 80px rgba(24, 23, 19, 0.18);
    overflow: clip;
  }

  .guess-form {
    bottom: 18px;
    border-radius: 0 0 28px 28px;
  }
}

@media (min-width: 700px) {
  body {
    min-height: 100svh;
    display: grid;
    place-items: center;
    overflow: hidden;
    padding: 24px;
    background:
      linear-gradient(90deg, rgba(24, 23, 19, 0.04) 1px, transparent 1px),
      linear-gradient(180deg, rgba(24, 23, 19, 0.04) 1px, transparent 1px),
      linear-gradient(180deg, #f3efe1, #dfe9df);
    background-size: 28px 28px, 28px 28px, auto;
  }

  .mobile-shell {
    width: min(390px, calc(100vw - 64px));
    height: min(844px, calc(100svh - 48px));
    min-height: 0;
    position: relative;
    padding: 42px 12px 98px;
    border: 10px solid var(--ink);
    border-radius: 42px;
    overflow-y: auto;
    scrollbar-width: none;
    box-shadow:
      0 36px 90px rgba(24, 23, 19, 0.26),
      inset 0 0 0 1px rgba(255, 255, 255, 0.38);
  }

  .mobile-shell::-webkit-scrollbar {
    display: none;
  }

  .mobile-shell::before {
    content: "";
    position: absolute;
    top: 17px;
    left: 50%;
    z-index: 30;
    width: 74px;
    height: 7px;
    border-radius: 999px;
    background: #27342c;
    transform: translateX(-50%);
    pointer-events: none;
  }

  .game-card {
    height: 100%;
    min-height: 0;
  }

  .guess-form {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    transform: none;
    border-radius: 0 0 31px 31px;
  }
}

@media (max-width: 360px) {
  .guess-table-head,
  .guess-row {
    grid-template-columns: minmax(64px, 0.8fr) minmax(0, 1fr);
  }

  .word-cell {
    font-size: 15px;
  }
}
