:root {
  --background: #101210;
  --foreground: #f4efe3;
  --panel: rgba(28, 29, 26, 0.8);
  --line: rgba(244, 239, 227, 0.16);
  --gold: #d5a467;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 18% 12%, rgba(213, 164, 103, 0.12), transparent 28%),
    linear-gradient(145deg, #171814 0%, #0d1311 52%, #1d1713 100%);
  color: var(--foreground);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.game-shell {
  min-height: 100vh;
  padding: clamp(18px, 3vw, 42px);
}

.brand-strip {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  max-width: 1320px;
  margin: 0 auto 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(34px, 5vw, 66px);
  line-height: 0.98;
  letter-spacing: 0;
}

.status-card {
  width: min(420px, 100%);
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(12, 13, 12, 0.55);
}

.status-card span,
.field span,
.score-grid span,
.mini span {
  display: block;
  color: rgba(244, 239, 227, 0.65);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.status-card strong {
  display: block;
  margin-top: 7px;
  color: #fffaf0;
  font-size: 15px;
  line-height: 1.35;
}

.lobby {
  max-width: 1320px;
  margin: 0 auto;
  padding: clamp(16px, 2.5vw, 26px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    rgba(20, 21, 18, 0.82);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.36);
}

.lobby-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1;
  letter-spacing: 0;
}

.lobby-start {
  min-width: 180px;
  padding: 0 18px;
}

.lobby-grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  gap: 14px;
}

.lobby-column {
  display: grid;
  align-content: start;
  gap: 10px;
}

.section-label {
  display: block;
  color: rgba(244, 239, 227, 0.62);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.choice-card {
  min-height: 92px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--foreground);
  text-align: left;
}

.choice-card strong {
  display: block;
  color: #fff7df;
  font-size: 18px;
  line-height: 1.15;
}

.choice-card span {
  display: block;
  margin-top: 8px;
  color: rgba(244, 239, 227, 0.7);
  font-size: 14px;
  line-height: 1.38;
}

.choice-card.selected {
  border-color: rgba(232, 196, 125, 0.72);
  background: linear-gradient(135deg, rgba(232, 196, 125, 0.18), rgba(255, 255, 255, 0.055));
  box-shadow: inset 0 0 0 1px rgba(232, 196, 125, 0.22);
}

.difficulty-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.difficulty-grid button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(244, 239, 227, 0.76);
  font-weight: 800;
}

.difficulty-grid .selected {
  border-color: rgba(232, 196, 125, 0.7);
  background: #f1e2c3;
  color: #16120e;
}

.room-lobby,
.lobby-summary {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.room-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.lobby-summary strong {
  color: #fff7df;
  line-height: 1.35;
}

.layout {
  display: grid;
  grid-template-columns: minmax(250px, 330px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  max-width: 1320px;
  margin: 0 auto;
}

.panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(18px);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.segmented button,
.primary,
.secondary {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  color: var(--foreground);
  font-weight: 800;
}

.segmented button {
  background: transparent;
  color: rgba(244, 239, 227, 0.72);
}

.segmented .selected {
  background: #f1e2c3;
  color: #16120e;
}

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

.field select,
.field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--foreground);
  padding: 0 12px;
  outline: none;
}

.field option {
  color: #15120f;
}

.rule-box {
  padding: 14px;
  border-left: 3px solid var(--gold);
  border-radius: 6px;
  background: rgba(213, 164, 103, 0.09);
}

.rule-box strong {
  display: block;
  color: #fff7df;
}

.rule-box p {
  margin: 6px 0 0;
  color: rgba(244, 239, 227, 0.72);
  font-size: 14px;
  line-height: 1.45;
}

.room-tools {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.primary {
  background: linear-gradient(135deg, #e8c47d, #c17d42);
  color: #18120c;
  box-shadow: 0 10px 24px rgba(193, 125, 66, 0.25);
}

.secondary {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
}

.score-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.score-grid div,
.mini {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.score-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 30px;
}

.mini {
  display: grid;
  gap: 9px;
}

.mini strong {
  color: #fff7df;
  font-size: 14px;
}

.sound-toggle {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--foreground);
  padding: 0 13px;
}

.sound-toggle span {
  color: rgba(244, 239, 227, 0.65);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.sound-toggle strong {
  min-width: 42px;
  border-radius: 999px;
  background: #f1e2c3;
  color: #16120e;
  padding: 4px 9px;
  font-size: 13px;
  text-align: center;
}

.sound-toggle.muted strong {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(244, 239, 227, 0.68);
}

.meter {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.meter i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #60c6a1, #efcb72, #e15d4d);
}

.table-wrap {
  position: relative;
  min-width: 0;
  padding: clamp(10px, 1.5vw, 16px);
  border: 1px solid rgba(213, 164, 103, 0.34);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent),
    #211913;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.4);
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 1;
  height: auto;
  border-radius: 6px;
  touch-action: none;
  user-select: none;
}

.table-overlay {
  position: absolute;
  inset: 16px;
  display: grid;
  place-content: center;
  gap: 9px;
  padding: 20px;
  border-radius: 6px;
  background: rgba(7, 10, 9, 0.38);
  text-align: center;
  pointer-events: none;
}

.table-overlay strong {
  font-size: clamp(22px, 3vw, 38px);
  line-height: 1;
}

.table-overlay span {
  max-width: 520px;
  color: rgba(244, 239, 227, 0.76);
  line-height: 1.45;
}

.result-overlay {
  position: absolute;
  inset: 16px;
  display: grid;
  place-content: center;
  gap: 12px;
  overflow: hidden;
  border-radius: 6px;
  background:
    radial-gradient(circle at center, rgba(232, 196, 125, 0.22), rgba(8, 10, 9, 0.74) 42%, rgba(5, 6, 6, 0.92)),
    rgba(5, 6, 6, 0.82);
  text-align: center;
  pointer-events: none;
  animation: resultFadeIn 360ms ease-out both;
}

.result-overlay::before,
.result-overlay::after {
  content: "";
  position: absolute;
  inset: -25%;
  background:
    linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.2), transparent 48%),
    repeating-radial-gradient(circle at center, rgba(232, 196, 125, 0.16) 0 2px, transparent 3px 18px);
  animation: resultSweep 2200ms ease-in-out infinite;
}

.result-overlay::after {
  animation-delay: 420ms;
  opacity: 0.45;
  transform: rotate(25deg);
}

.result-burst {
  position: absolute;
  width: 190px;
  height: 190px;
  place-self: center;
  border: 1px solid rgba(232, 196, 125, 0.38);
  border-radius: 999px;
  box-shadow: 0 0 0 18px rgba(232, 196, 125, 0.08), 0 0 70px rgba(232, 196, 125, 0.36);
  animation: resultPulse 980ms ease-out infinite;
}

.result-overlay p,
.result-overlay strong,
.result-overlay span {
  position: relative;
  z-index: 1;
}

.result-overlay p {
  margin: 0;
  color: var(--gold);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.result-overlay strong {
  color: #fff7df;
  font-size: clamp(44px, 8vw, 106px);
  line-height: 0.9;
  text-shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
  animation: resultPop 520ms cubic-bezier(0.2, 1.4, 0.25, 1) both;
}

.result-overlay span {
  color: rgba(244, 239, 227, 0.8);
  font-weight: 800;
}

.result-overlay.loss {
  background:
    radial-gradient(circle at center, rgba(207, 62, 53, 0.2), rgba(8, 10, 9, 0.76) 42%, rgba(5, 6, 6, 0.94)),
    rgba(5, 6, 6, 0.86);
}

.result-overlay.loss .result-burst {
  border-color: rgba(207, 62, 53, 0.44);
  box-shadow: 0 0 0 18px rgba(207, 62, 53, 0.08), 0 0 70px rgba(207, 62, 53, 0.3);
}

@keyframes resultFadeIn {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes resultPop {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.86);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes resultPulse {
  from {
    opacity: 0.85;
    transform: scale(0.75);
  }
  to {
    opacity: 0;
    transform: scale(1.6);
  }
}

@keyframes resultSweep {
  from {
    transform: translateX(-18%) rotate(0deg);
  }
  to {
    transform: translateX(18%) rotate(12deg);
  }
}

@media (max-width: 920px) {
  .brand-strip {
    display: grid;
  }

  .lobby-head {
    display: grid;
  }

  .lobby-start {
    width: 100%;
  }

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

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

  .panel {
    order: 2;
  }
}

@media (max-width: 560px) {
  .game-shell {
    padding: 14px;
  }

  h1 {
    font-size: 32px;
  }

  .room-tools,
  .difficulty-grid,
  .room-actions,
  .score-grid {
    grid-template-columns: 1fr;
  }

  .segmented button,
  .primary,
  .secondary,
  .field select,
  .field input {
    min-height: 42px;
  }
}
