:root {
  color-scheme: light;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, #f9f5d7 0%, rgba(249, 245, 215, 0) 40%),
    linear-gradient(180deg, #90c9ff 0%, #d6efff 55%, #f8f2dd 100%);
  color: #15314b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

#app {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 40px;
}

.page-header {
  margin-bottom: 24px;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(2.4rem, 6vw, 4rem);
  line-height: 0.95;
}

.intro,
.controls-list,
.feedback,
.player-list {
  font-size: 1rem;
  line-height: 1.5;
}

.layout {
  display: grid;
  gap: 20px;
}

.panel {
  padding: 20px;
  border: 1px solid rgba(21, 49, 75, 0.12);
  border-radius: 18px;
  background: rgba(255, 252, 245, 0.78);
  box-shadow: 0 18px 40px rgba(33, 76, 112, 0.12);
  backdrop-filter: blur(8px);
}

.panel-large {
  min-width: 0;
}

.panel-stack {
  display: grid;
  gap: 18px;
  align-content: start;
}

.panel-block + .panel-block {
  padding-top: 18px;
  border-top: 1px solid rgba(21, 49, 75, 0.1);
}

.canvas-root {
  overflow: hidden;
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px rgba(21, 49, 75, 0.14);
}

.game-canvas {
  display: block;
  width: 100%;
  height: auto;
  background: linear-gradient(180deg, #82c5ff 0%, #d8f2ff 74%, #c69757 74%, #d8bc72 100%);
}

.button,
.text-input {
  border-radius: 12px;
  font: inherit;
}

.button {
  border: 1px solid rgba(21, 49, 75, 0.18);
  background: #fff8ea;
  color: #15314b;
  padding: 10px 16px;
  cursor: pointer;
}

.button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.button-primary {
  border-color: #995115;
  background: linear-gradient(180deg, #f9b14d 0%, #dc7d2d 100%);
  color: #fff9ef;
  font-weight: 700;
}

.button-secondary {
  font-weight: 700;
}

.button-secondary:disabled {
  cursor: not-allowed;
}

.action-row {
  display: grid;
  gap: 10px;
}

.join-form {
  margin-top: 16px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.9rem;
  font-weight: 700;
}

.join-row {
  display: grid;
  gap: 10px;
}

.text-input {
  width: 100%;
  border: 1px solid rgba(21, 49, 75, 0.16);
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.92);
  color: inherit;
}

.feedback {
  min-height: 1.5em;
  margin-bottom: 0;
  color: #8a4f18;
}

.player-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0;
  margin-top: 26px;
  margin-bottom: 0;
  list-style: none;
}

.player-card {
  position: relative;
  min-width: 0;
  padding: 34px 14px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(21, 49, 75, 0.1);
}

.player-card.is-current {
  border-color: rgba(138, 79, 24, 0.35);
  box-shadow: inset 0 0 0 1px rgba(138, 79, 24, 0.22);
}

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

.player-name {
  font-weight: 700;
}

.score-cluster {
  position: absolute;
  top: 0;
  left: 50%;
  width: 42px;
  height: 42px;
  transform: translate(-50%, -50%);
}

.score-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 700;
  color: #fff9ef;
  box-shadow: 0 8px 18px rgba(21, 49, 75, 0.16);
}

.score-circle.is-leading {
  background: linear-gradient(180deg, #f7d774 0%, #d28a24 100%);
  color: #5a3b00;
}

.score-circle.is-trailing {
  background: linear-gradient(180deg, #7eb7f4 0%, #3f78b4 100%);
}

.score-circle.is-tied {
  background: linear-gradient(180deg, #977ee2 0%, #6747b7 100%);
}

.score-crown {
  position: absolute;
  left: 53%;
  bottom: 100%;
  width: 30px;
  height: 28px;
  transform: translate(-50%, 3px);
  background: linear-gradient(180deg, #ffd86c 0%, #d4881f 100%);
  clip-path: polygon(8% 100%, 0% 34%, 30% 65%, 42% 8%, 55% 65%, 88% 34%, 80% 100%);
  box-shadow: 0 3px 8px rgba(112, 70, 7, 0.22);
}

.player-status-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex: 0 0 auto;
}

.player-state {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.85rem;
  background: rgba(94, 117, 136, 0.12);
}

.player-state.is-connected {
  background: rgba(66, 122, 49, 0.16);
  color: #2f6c24;
}

.player-marker {
  min-height: 1.25rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #8a4f18;
}

.player-detail {
  display: block;
  margin-top: 6px;
  color: #5e7588;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.controls-list {
  padding-left: 18px;
  margin-bottom: 0;
  font-size: 0.92rem;
}

.debug-copy {
  margin-bottom: 12px;
  color: #5e7588;
  font-size: 0.94rem;
}

.debug-textarea {
  width: 100%;
  min-height: 320px;
  padding: 10px 12px;
  border: 1px solid rgba(21, 49, 75, 0.16);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: inherit;
  font: 13px/1.45 "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  resize: vertical;
}

@media (min-width: 860px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 400px;
    align-items: start;
  }

  .join-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .action-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}
