* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: #dfe9df;
  color: #172017;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  overscroll-behavior: none;
}

body[data-screen='game'] {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: #d54a35;
  color: #fffdf4;
  cursor: pointer;
  font-weight: 800;
}

button.secondary {
  background: #fffdf4;
  color: #233022;
  border: 1px solid #b5c5ad;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid #b5c5ad;
  border-radius: 8px;
  background: #fffdf4;
  color: #172017;
  padding: 0 12px;
  text-transform: uppercase;
}

.shell {
  width: 100%;
  min-height: 100dvh;
}

.screen {
  width: min(520px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 18px 0 max(24px, env(safe-area-inset-bottom));
}

.screen[hidden] {
  display: none;
}

.lobby-screen,
.room-screen {
  display: grid;
  gap: 12px;
  align-content: start;
}

.lobby-header,
.room-header {
  padding-top: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: #d54a35;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

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

h1 {
  margin-bottom: 0;
  font-size: 42px;
  line-height: 1;
}

h2 {
  margin-bottom: 10px;
  font-size: 16px;
}

p {
  color: #51614f;
  line-height: 1.55;
}

.connection-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  top: max(10px, env(safe-area-inset-top));
  z-index: 30;
  max-width: 520px;
  margin: 0 auto;
  border: 1px solid rgba(35, 48, 34, 0.14);
  border-radius: 8px;
  background: rgba(255, 253, 244, 0.9);
  color: #233022;
  padding: 8px 10px;
  font-size: 13px;
  text-align: center;
  backdrop-filter: blur(14px);
}

body[data-screen='lobby'] .connection-banner,
body:not([data-screen]) .connection-banner {
  position: static;
  margin-top: 12px;
}

body[data-screen='room'] .connection-banner {
  position: static;
  margin-top: 12px;
}

body[data-screen='game'] .connection-banner {
  display: none;
}

.panel-section {
  border: 1px solid #b5c5ad;
  border-radius: 8px;
  background: #f7f3e5;
  padding: 14px;
}

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

.solo-button {
  background: #77dcb8;
  color: #0f2a20;
}

.join-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px;
  gap: 8px;
}

label {
  display: block;
  margin-bottom: 6px;
  color: #51614f;
  font-size: 13px;
}

.ghost-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 8px;
  color: #233022;
  text-decoration: none;
}

#copy-link {
  width: 100%;
}

.character-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.speed-mode-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.character-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  margin: 0;
  border: 1px solid #b5c5ad;
  border-radius: 8px;
  background: #fffdf4;
  color: #172017;
  padding: 8px 10px;
  font-weight: 800;
}

.speed-mode-option {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  margin: 0;
  border: 1px solid #b5c5ad;
  border-radius: 8px;
  background: #fffdf4;
  color: #172017;
  padding: 8px 6px;
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}

.character-option input,
.speed-mode-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.character-option.is-selected,
.speed-mode-option.is-selected {
  border-color: #d54a35;
  background: #fff1df;
}

.character-swatch {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(23, 32, 23, 0.35);
  border-radius: 50%;
  background: var(--character-color);
}

.room-header h1 {
  font-size: 54px;
  letter-spacing: 0;
}

.status-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.status-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status-list dt {
  color: #697867;
}

.status-list dd {
  margin: 0;
  color: #172017;
  font-weight: 800;
}

.game-screen {
  width: 100%;
  min-height: 100dvh;
  padding: 0;
}

.game-hud {
  position: fixed;
  left: 10px;
  right: 10px;
  top: max(10px, env(safe-area-inset-top));
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid rgba(35, 48, 34, 0.14);
  border-radius: 8px;
  background: rgba(255, 253, 244, 0.86);
  padding: 8px 10px;
  backdrop-filter: blur(14px);
}

.game-hud div {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 14px;
  font-weight: 800;
}

#score-label {
  color: #d54a35;
  font-size: 18px;
}

#turn-label {
  color: #233022;
  white-space: nowrap;
}

.icon-text-button {
  min-height: 36px;
  padding: 0 12px;
  background: #fffdf4;
  color: #233022;
  font-size: 13px;
}

.play-surface {
  position: relative;
  overflow: hidden;
  width: 100vw;
  height: 100dvh;
  min-height: 360px;
  border: 0;
  border-radius: 0;
  background: #dfe9df;
  touch-action: none;
}

.play-surface.is-dragging {
  cursor: grabbing;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

@media (min-width: 760px) {
  .screen {
    width: min(620px, calc(100vw - 48px));
    padding-top: 30px;
  }

  h1 {
    font-size: 56px;
  }

  .primary-actions {
    grid-template-columns: 1fr 1fr;
  }

  .connection-banner {
    left: 50%;
    right: auto;
    width: min(620px, calc(100vw - 48px));
    transform: translateX(-50%);
  }

  body[data-screen='lobby'] .connection-banner,
  body:not([data-screen]) .connection-banner,
  body[data-screen='room'] .connection-banner {
    transform: none;
  }

  .game-hud {
    left: 50%;
    right: auto;
    width: min(820px, calc(100vw - 32px));
    transform: translateX(-50%);
  }
}
