:root {
  color-scheme: light;
  --paper: #f7f3ea;
  --ink: #202124;
  --muted: #6a6257;
  --line: #d8cfbf;
  --panel: #fffaf1;
  --panel-strong: #ffffff;
  --accent: #0f7a5f;
  --accent-dark: #075e4a;
  --coral: #c84f3d;
  --gold: #d69a24;
  --shadow: 0 16px 40px rgba(32, 33, 36, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(15, 122, 95, 0.13), transparent 36%),
    linear-gradient(315deg, rgba(200, 79, 61, 0.12), transparent 34%),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.hidden {
  display: none !important;
}

.join-view {
  min-height: calc(100vh - 56px);
  display: grid;
  align-content: center;
  gap: 26px;
  max-width: 520px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mark {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--coral));
  color: #fff;
  font-weight: 800;
  box-shadow: var(--shadow);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 2rem;
  line-height: 1.1;
}

h2 {
  font-size: 1rem;
}

.brand-row p,
.eyebrow,
.form-error,
.muted,
.meta {
  color: var(--muted);
}

.join-form {
  display: grid;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: var(--panel-strong);
  color: var(--ink);
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 122, 95, 0.15);
}

.primary-action,
.quiet-button,
.icon-button,
.tool-tab,
.avatar-choice,
.target-button,
.toggle-button {
  border-radius: 8px;
  min-height: 40px;
}

.primary-action {
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  padding: 12px 16px;
}

.primary-action:hover {
  background: var(--accent-dark);
}

.form-error {
  min-height: 1.2rem;
  color: var(--coral);
  font-weight: 700;
}

.game-view {
  display: grid;
  gap: 18px;
}

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

.eyebrow {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar-actions,
.tool-tabs,
.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.quiet-button,
.icon-button,
.tool-tab,
.toggle-button {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 800;
  padding: 9px 12px;
}

.quiet-button:hover,
.icon-button:hover,
.tool-tab:hover,
.toggle-button:hover {
  border-color: var(--accent);
}

.tool-tab.is-active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.layout {
  display: grid;
  grid-template-columns: minmax(290px, 380px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  background: rgba(255, 250, 241, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.count-pill,
.status-pill {
  min-width: 32px;
  border-radius: 8px;
  display: inline-flex;
  justify-content: center;
  background: #efe4d1;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 4px 8px;
}

.players-grid {
  display: grid;
  gap: 10px;
}

.player-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 68px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.player-card.is-out {
  opacity: 0.48;
  filter: grayscale(0.85);
}

.player-card.is-self {
  border-color: var(--accent);
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  border: 2px solid rgba(255, 255, 255, 0.7);
}

.player-main {
  min-width: 0;
}

.player-name {
  font-weight: 900;
  overflow-wrap: anywhere;
}

.player-flags {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.status-pill {
  background: #f1eadf;
}

.status-pill.warn {
  background: #f8decf;
  color: #9a3412;
}

.number-box {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.number-input {
  width: 64px;
  text-align: center;
  font-weight: 900;
  padding: 8px 6px;
}

.out-toggle {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 5px;
}

.out-toggle input {
  width: 16px;
  height: 16px;
}

.self-editor {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.self-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 10px;
}

.avatar-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.avatar-choice {
  width: 42px;
  height: 42px;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 900;
  flex: 0 0 auto;
  border: 2px solid transparent;
}

.avatar-choice.is-active {
  border-color: var(--ink);
}

.tool-content {
  display: grid;
  gap: 14px;
}

.tool-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.tool-title {
  display: grid;
  gap: 4px;
}

.target-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.target-button {
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.target-button:hover,
.target-button.is-picked {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 122, 95, 0.12);
}

.target-button .avatar {
  width: 40px;
  height: 40px;
  font-size: 0.78rem;
}

.result-box,
.killer-box {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.result-name {
  font-size: 1.3rem;
  font-weight: 900;
}

.meter {
  height: 12px;
  border-radius: 8px;
  background: #efe4d1;
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--coral));
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  max-width: min(420px, calc(100% - 28px));
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  font-weight: 800;
  z-index: 20;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding: 16px 0;
  }

  .topbar {
    display: grid;
  }

  .self-fields {
    grid-template-columns: 1fr;
  }

  .player-card {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .number-box {
    grid-column: 1 / -1;
    grid-template-columns: 82px 1fr;
    justify-items: start;
    align-items: center;
  }
}

