:root {
  --bg: #fff3d6;
  --ink: #2d1c12;
  --muted: rgba(45, 28, 18, 0.62);
  --panel: rgba(255, 252, 239, 0.88);
  --line: rgba(94, 61, 34, 0.18);
  --green: #39c46b;
  --orange: #ffb23f;
  --red: #ec5b57;
  --blue: #4aa9ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 178, 63, 0.42), transparent 26%),
    radial-gradient(circle at 84% 24%, rgba(74, 169, 255, 0.32), transparent 25%),
    linear-gradient(135deg, #ffe8a8, #ffd5c4 50%, #c9ecff);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
}

.app {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
  padding: 18px 0;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

.floating-timer {
  position: fixed;
  top: 10px;
  right: 14px;
  z-index: 50;
  display: grid;
  grid-template-columns: auto auto;
  gap: 8px;
  align-items: baseline;
  border: 1px solid rgba(94, 61, 34, 0.22);
  border-radius: 999px;
  padding: 9px 13px;
  background: rgba(45, 28, 18, 0.92);
  color: #fff3d6;
  box-shadow: 0 10px 26px rgba(45, 28, 18, 0.22);
}

.floating-timer span {
  color: rgba(255, 243, 214, 0.72);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.floating-timer strong {
  font-size: 22px;
  line-height: 1;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 18px 44px rgba(80, 48, 22, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(10px);
}

.join-panel {
  width: min(430px, 100%);
  margin: 12vh auto 0;
  padding: 28px;
}

.eyebrow,
.topbar span,
label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(38px, 9vw, 64px);
  line-height: 0.95;
}

h2 {
  margin-bottom: 12px;
}

.intro {
  color: var(--muted);
  font-weight: 700;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

input,
select {
  width: 100%;
  border: 1px solid rgba(94, 61, 34, 0.22);
  border-radius: 10px;
  padding: 12px 13px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  font: 900 17px/1.2 system-ui, sans-serif;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(74, 169, 255, 0.14);
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 12px 16px;
  background: linear-gradient(180deg, #52e889, #22b858);
  color: #062512;
  font: 900 16px/1 system-ui, sans-serif;
  white-space: normal;
  text-align: center;
  box-shadow: 0 7px 0 #168640, 0 13px 24px rgba(22, 134, 64, 0.2);
  cursor: pointer;
}

button:active {
  transform: translateY(3px);
  box-shadow: 0 4px 0 #168640, 0 9px 18px rgba(22, 134, 64, 0.18);
}

button.secondary {
  background: linear-gradient(180deg, #ffe083, #ffb23f);
  color: #331d00;
  box-shadow: 0 7px 0 #be7718, 0 13px 24px rgba(190, 119, 24, 0.2);
}

button.subtle {
  background: linear-gradient(180deg, #f7f1df, #e5d4b4);
  color: #4b3826;
  box-shadow: 0 7px 0 #b49a72, 0 13px 24px rgba(94, 61, 34, 0.16);
}

button.danger {
  background: linear-gradient(180deg, #ff9b9b, #ec5b57);
  color: #320908;
  box-shadow: 0 7px 0 #ab3633, 0 13px 24px rgba(171, 54, 51, 0.2);
}

button:disabled {
  opacity: 0.55;
  cursor: default;
}

.topbar {
  position: sticky;
  top: 8px;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(255, 243, 214, 0.72);
  backdrop-filter: blur(10px);
}

.topbar div {
  display: grid;
  gap: 4px;
  min-height: 76px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 252, 239, 0.8);
  box-shadow: inset 0 0 0 1px var(--line);
}

.topbar strong {
  font-size: 34px;
  line-height: 1;
}

#letterLabel {
  color: var(--red);
}

.content {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 12px;
}

.sidebar,
.play-area {
  padding: 18px;
}

.score-list {
  display: grid;
  gap: 8px;
  margin: 0 0 18px;
  padding-left: 24px;
}

.score-list li {
  font-weight: 900;
}

.score-list small {
  display: block;
  color: var(--muted);
  font-weight: 800;
}

.controls {
  display: grid;
  gap: 10px;
}

.state-card {
  display: grid;
  min-height: 360px;
  place-items: center;
  text-align: center;
}

.answer-form {
  display: grid;
  gap: 14px;
}

.form-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
}

.form-head p {
  max-width: 420px;
  margin-bottom: 12px;
  color: var(--muted);
  font-weight: 750;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.category-grid label {
  margin: 0;
}

.status-text {
  min-height: 22px;
  margin: 0;
  color: var(--green);
  font-weight: 900;
}

.results-table {
  max-width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.answer-ok {
  color: #12743b;
  font-weight: 900;
}

.answer-dup {
  color: #a86600;
  font-weight: 900;
}

.answer-bad {
  color: rgba(45, 28, 18, 0.42);
  font-weight: 800;
}

@media (max-width: 850px) {
  body {
    background:
      radial-gradient(circle at 12% 8%, rgba(255, 178, 63, 0.34), transparent 28%),
      linear-gradient(160deg, #ffe8a8, #ffd5c4 52%, #d7f4ff);
  }

  .app {
    width: 100%;
    padding: 58px 8px 8px;
  }

  .floating-timer {
    top: max(8px, env(safe-area-inset-top));
    right: 8px;
    left: 8px;
    grid-template-columns: auto 1fr;
    border-radius: 12px;
    padding: 9px 12px;
  }

  .floating-timer strong {
    justify-self: end;
    font-size: 25px;
  }

  .topbar {
    top: 0;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-bottom: 8px;
    padding: 5px;
  }

  .topbar div {
    min-height: 58px;
    padding: 8px 10px;
  }

  .topbar strong {
    font-size: 24px;
  }

  .content {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .panel {
    border-radius: 12px;
    box-shadow: 0 10px 24px rgba(80, 48, 22, 0.12);
    backdrop-filter: none;
  }

  .sidebar,
  .play-area {
    min-width: 0;
    padding: 14px;
  }

  h2 {
    font-size: 26px;
  }

  .score-list {
    margin-bottom: 14px;
  }

  .controls {
    gap: 9px;
  }

  button {
    min-height: 50px;
    padding: 11px 12px;
    font-size: 15px;
    line-height: 1.1;
  }

  .category-grid {
    grid-template-columns: 1fr;
  }

  .form-head {
    display: block;
  }

  .form-head p {
    max-width: none;
    font-size: 15px;
  }

  .results-table {
    overflow-x: visible;
  }

  .results-table table,
  .results-table thead,
  .results-table tbody,
  .results-table tr,
  .results-table th,
  .results-table td {
    display: block;
    min-width: 0;
    width: 100%;
  }

  .results-table table {
    border-collapse: separate;
  }

  .results-table thead {
    display: none;
  }

  .results-table tr {
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.48);
    overflow: hidden;
  }

  .results-table td {
    display: grid;
    grid-template-columns: 118px 1fr;
    gap: 8px;
    padding: 9px 10px;
    border-bottom: 1px solid var(--line);
    word-break: break-word;
  }

  .results-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
  }

  .results-table td:last-child {
    border-bottom: 0;
  }
}

.join-divider{text-align:center;color:var(--muted);font-size:12px;margin:16px 0}.join-panel button{width:100%;min-height:44px}.join-panel{max-height:none}.join-panel #codeInput{text-transform:uppercase;letter-spacing:3px}.room-share{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:10px;background:var(--panel);border:1px solid var(--line);border-radius:16px;padding:12px}.room-share>span{flex:1;font-size:13px}.room-share strong{font-size:22px;letter-spacing:3px;display:inline-block;margin-left:7px}.room-share button{min-height:44px;padding:8px 12px;font-size:12px}#roomMessage,#joinStatus,#hostNote{font-size:12px;line-height:1.5;overflow-wrap:anywhere}#joinStatus{color:#9b3433;min-height:18px;margin-bottom:0}#hostNote{color:var(--muted)}

.room-share>span{flex-basis:100%}.room-share button{width:auto;flex:1}
/* The grid must be allowed to shrink instead of clipping its results. */
.content{grid-template-columns:250px minmax(0,1fr)}.sidebar,.play-area,.results,.results-table,.form-head>*{min-width:0}.app{overflow-x:visible}.results-table{overflow:visible}.form-head{align-items:start;flex-wrap:wrap}.form-head p{font-size:13px;flex:1;min-width:200px;max-width:420px}.category-results-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}.category-results{min-width:0;border:1px solid var(--line);border-radius:16px;background:#fffdf4;padding:14px}.category-results h3{margin:0 0 12px;font-size:16px;overflow-wrap:anywhere}.answer-card{padding:12px;border:1px solid #e6dccb;border-radius:12px;margin-top:8px;background:#faf6ec;overflow-wrap:anywhere}.answer-card-head{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:11px;color:var(--ink)}.answer-card-head>span{flex:none;font-size:10px;font-weight:750;padding:4px 7px;border-radius:8px;background:#fff}.answer-word{margin:9px 0 4px;font-size:16px;line-height:1.4}.answer-reason,.vote-count,.vote-note{font-size:11px;line-height:1.5;margin:5px 0;font-weight:500;color:#78684f}.answer-bad{color:#806d5c}.answer-pending{background:#fff3d9;color:#85601e}.own-answer{border-color:#b4c9a2}.vote-controls{display:flex;align-items:center;gap:10px;margin-top:12px}.vote-check{display:flex;align-items:center;justify-content:center;gap:7px;flex:1;margin:0;min-height:44px;padding:8px;border:1px solid #b2c7a2;border-radius:10px;background:#ecf4e3;cursor:pointer}.vote-check input{width:20px;height:20px;margin:0;padding:0;accent-color:#188748;box-shadow:none}.vote-check span{font-size:12px;text-transform:none;letter-spacing:0;color:#345c2f;font-weight:750}.vote-refuse{width:auto;flex:1;min-height:44px;background:#f4e8df;border:1px solid #dbc0ae;box-shadow:none;color:#865b41;padding:9px;font-size:12px}.review-status{font-size:13px;line-height:1.6;color:#6e604a;margin:0 0 15px}.room-share>span{flex:1;flex-basis:auto}.room-share button{flex:none;width:auto}.room-share>span,.score-list li{overflow-wrap:anywhere}
@media(max-width:1000px){.content{grid-template-columns:210px minmax(0,1fr)}.category-results-grid{grid-template-columns:1fr}.sidebar{padding:14px}.form-head p{min-width:0;flex-basis:100%}}
@media(max-width:850px){.app{padding:12px 10px}.content{display:flex;flex-direction:column}.play-area{order:0}.sidebar{order:1}.topbar{position:static;grid-template-columns:repeat(4,minmax(0,1fr))}.topbar div{padding:8px 7px;min-height:57px}.topbar span{font-size:9px}.topbar strong{font-size:21px}.room-share{gap:8px}.room-share>span{flex-basis:100%}.room-share button{flex:1;min-height:44px}.score-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px 20px;font-size:13px}.controls{grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.controls #hostNote{grid-column:1/-1;margin:0}.controls label{margin:0}.controls button{font-size:12px;line-height:1.3}.category-results-grid{grid-template-columns:1fr;gap:12px}.category-results{padding:12px}.answer-card{padding:12px}.form-head p{font-size:12px}.form-head h2{font-size:23px}.join-panel{margin:6vh auto 0;padding:24px}.floating-timer{left:auto;right:10px;top:10px;border-radius:20px;padding:7px 11px;grid-template-columns:auto auto;pointer-events:none}.floating-timer strong{font-size:18px}.floating-timer span{font-size:9px}body:has(#floatingTimer:not(.hidden)) .app{padding-top:54px}}
@media(max-width:360px){.controls{grid-template-columns:1fr}.vote-controls{gap:7px}.topbar strong{font-size:18px}.answer-card-head{flex-wrap:wrap}}
.content{align-items:start}
