:root {
  color-scheme: light;
  --bg: #f3f7ff;
  --ink: #162033;
  --muted: #60708b;
  --line: rgba(33, 54, 84, 0.14);
  --card: #ffffff;
  --blue: #0aa3ff;
  --blue-dark: #087ad5;
  --mint: #16c79a;
  --pink: #ff5d8f;
  --yellow: #ffd447;
  --shadow: 0 18px 40px rgba(27, 73, 130, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 15% 5%, rgba(255, 212, 71, 0.42), transparent 24rem),
    radial-gradient(circle at 88% 20%, rgba(255, 93, 143, 0.22), transparent 18rem),
    linear-gradient(180deg, #eaf5ff 0%, var(--bg) 48%, #f8fbff 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 34px;
}

.topbar,
.room-header,
.room-actions,
.button-row,
.brand,
.nav-pills {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.brand {
  gap: 10px;
  color: var(--ink);
  font-size: 1.06rem;
  font-weight: 900;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: white;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--blue), var(--pink));
  box-shadow: 0 10px 20px rgba(10, 163, 255, 0.28);
}

.nav-pills {
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(18px);
}

.pill {
  min-height: 36px;
  padding: 0 16px;
  color: var(--muted);
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-weight: 800;
}

.pill.active {
  color: #fff;
  background: var(--ink);
}

.lobby {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) 380px;
  gap: 22px;
  align-items: start;
}

.lobby-copy {
  padding: 30px 0 10px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--blue-dark);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.lobby-copy h1,
.room-header h1 {
  margin-bottom: 14px;
  font-size: clamp(2.2rem, 6vw, 4.2rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.lobby-copy p:not(.eyebrow) {
  max-width: 640px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.7;
}

.join-panel,
.word-controls {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.join-panel {
  position: sticky;
  top: 18px;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 900;
}

input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  color: var(--ink);
  border: 2px solid transparent;
  border-radius: 8px;
  outline: 1px solid var(--line);
  background: #f8fbff;
}

input:focus {
  border-color: var(--blue);
  outline-color: transparent;
  background: white;
}

.primary-button,
.show-button,
.ghost-button,
.danger-button,
.kick-button {
  min-height: 46px;
  border-radius: 8px;
  font-weight: 900;
}

.primary-button {
  width: 100%;
  color: white;
  border: 0;
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  box-shadow: 0 12px 24px rgba(10, 163, 255, 0.24);
}

.show-button {
  color: white;
  border: 0;
  background: linear-gradient(135deg, var(--pink), #b53cff);
  box-shadow: 0 12px 24px rgba(255, 93, 143, 0.22);
}

.ghost-button {
  padding: 0 16px;
  color: var(--ink);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.danger-button {
  padding: 0 16px;
  color: #fff;
  border: 0;
  background: #e53d63;
}

.form-error {
  min-height: 20px;
  margin: 12px 0 0;
  color: #d12655;
  font-size: 0.92rem;
  font-weight: 800;
}

.game-shelf {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.game-card {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 16px;
  align-items: center;
  min-height: 132px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 12px 26px rgba(27, 73, 130, 0.1);
}

.game-card h2 {
  margin-bottom: 8px;
  font-size: 1.25rem;
}

.game-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.game-art {
  display: grid;
  width: 96px;
  height: 96px;
  place-items: center;
  border-radius: 8px;
  font-size: 3rem;
  font-weight: 950;
}

.word-art {
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255, 212, 71, 0.95), rgba(22, 199, 154, 0.92)),
    var(--yellow);
}

.dice-art {
  color: white;
  background: linear-gradient(135deg, #7b61ff, #ff5d8f);
}

.muted {
  opacity: 0.76;
}

.hidden {
  display: none;
}

.room {
  min-height: calc(100vh - 90px);
  min-height: calc(100dvh - 90px);
}

.room-header {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
}

.room-header h1 {
  font-size: clamp(2rem, 5vw, 3.8rem);
}

.room-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.round-badge {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--yellow);
  font-weight: 950;
}

.status-line,
.hint {
  color: var(--muted);
  font-size: 0.95rem;
}

.status-line {
  margin-bottom: 16px;
  font-weight: 800;
}

.players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  min-height: 142px;
  margin-bottom: 18px;
}

.player-card {
  position: relative;
  min-height: 126px;
  padding: 34px 16px 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  box-shadow: 0 10px 26px rgba(27, 73, 130, 0.1);
}

.player-card.self-card {
  min-height: 172px;
  padding: 42px 22px 22px;
  border: 3px solid rgba(10, 163, 255, 0.32);
  background:
    linear-gradient(135deg, rgba(10, 163, 255, 0.08), rgba(255, 255, 255, 0.94)),
    white;
}

.player-number {
  position: absolute;
  top: 12px;
  left: 12px;
  display: inline-grid;
  min-width: 34px;
  height: 28px;
  place-items: center;
  color: white;
  border-radius: 8px;
  background: var(--ink);
  font-size: 0.84rem;
  font-weight: 950;
}

.player-card h2 {
  margin-bottom: 0;
  font-size: 1.08rem;
}

.self-card h2 {
  font-size: 1.55rem;
}

.player-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-right: 18px;
}

.owner-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  color: var(--ink);
  border-radius: 999px;
  background: var(--yellow);
  font-size: 0.78rem;
  font-weight: 950;
}

.player-status {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.word-slot {
  display: flex;
  min-height: 44px;
  align-items: center;
  margin-top: 10px;
  padding: 8px 10px;
  color: var(--ink);
  border-radius: 8px;
  background: #eef5ff;
  font-weight: 950;
  overflow-wrap: anywhere;
}

.word-slot.visible {
  background: var(--yellow);
}

.word-slot.locked {
  color: #6e7890;
  background: repeating-linear-gradient(
    135deg,
    #eef3fb 0,
    #eef3fb 8px,
    #e3ebf6 8px,
    #e3ebf6 16px
  );
}

.word-slot.empty {
  color: #8a96aa;
  background: #f5f8fc;
  border: 1px dashed rgba(33, 54, 84, 0.16);
}

.state-dot {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #aab5c5;
}

.state-dot.online {
  background: var(--mint);
}

.kick-button {
  position: absolute;
  right: 12px;
  bottom: 12px;
  min-height: 34px;
  padding: 0 12px;
  color: #d12655;
  border: 1px solid rgba(209, 38, 85, 0.22);
  background: rgba(255, 255, 255, 0.86);
  font-size: 0.84rem;
}

.empty-state {
  display: grid;
  min-height: 126px;
  place-items: center;
  padding: 20px;
  color: var(--muted);
  border: 1px dashed rgba(33, 54, 84, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
  font-weight: 800;
  text-align: center;
}

.self-zone {
  margin-bottom: 18px;
}

.word-controls {
  position: sticky;
  bottom: 16px;
}

.button-row {
  gap: 10px;
}

.button-row > button {
  flex: 1 1 0;
}

.hint {
  margin: 12px 0 0;
}

@media (max-width: 760px) {
  body {
    background:
      radial-gradient(circle at 12% 0%, rgba(255, 212, 71, 0.35), transparent 16rem),
      linear-gradient(180deg, #eaf5ff 0%, #f8fbff 100%);
  }

  .app-shell {
    width: min(100% - 16px, 1120px);
    padding: 10px 0 calc(18px + env(safe-area-inset-bottom));
  }

  .topbar {
    gap: 10px;
    margin-bottom: 12px;
  }

  .brand {
    font-size: 0.98rem;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 8px;
  }

  .nav-pills {
    gap: 6px;
    padding: 5px;
    overflow-x: auto;
  }

  .pill {
    min-height: 32px;
    padding: 0 12px;
    font-size: 0.88rem;
    white-space: nowrap;
  }

  .room-header {
    position: sticky;
    top: 0;
    z-index: 4;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin: 0 0 10px;
    padding: 10px 8px;
    border-bottom: 1px solid rgba(33, 54, 84, 0.08);
    background: rgba(243, 247, 255, 0.9);
    backdrop-filter: blur(14px);
  }

  .room-actions {
    width: 100%;
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: 8px;
    justify-content: flex-start;
  }

  .room-actions .ghost-button,
  .room-actions .danger-button {
    min-height: 38px;
    padding: 0 10px;
    font-size: 0.86rem;
  }

  .round-badge {
    min-height: 38px;
    padding: 0 10px;
    white-space: nowrap;
  }

  .lobby,
  .game-shelf {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .lobby-copy {
    padding: 0;
  }

  .lobby-copy h1,
  .room-header h1 {
    margin-bottom: 6px;
    font-size: clamp(1.6rem, 9vw, 2.25rem);
    line-height: 1;
  }

  .lobby-copy p:not(.eyebrow) {
    margin-bottom: 0;
    font-size: 0.92rem;
    line-height: 1.45;
  }

  .join-panel {
    position: static;
    padding: 16px;
  }

  label {
    margin-bottom: 12px;
  }

  input {
    min-height: 46px;
  }

  .game-card {
    grid-template-columns: 64px 1fr;
    min-height: 104px;
    padding: 12px;
    gap: 12px;
  }

  .game-art {
    width: 64px;
    height: 64px;
    font-size: 2rem;
  }

  .game-card h2 {
    margin-bottom: 4px;
    font-size: 1.04rem;
  }

  .game-card p {
    font-size: 0.9rem;
  }

  .status-line {
    margin-bottom: 10px;
    font-size: 0.86rem;
  }

  .players-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-height: 104px;
    gap: 8px;
    margin-bottom: 10px;
  }

  .player-card {
    min-height: 108px;
    padding: 30px 10px 12px;
    border-radius: 8px;
  }

  .player-card.self-card {
    min-height: 132px;
    padding: 34px 14px 14px;
    border-width: 2px;
  }

  .player-number {
    top: 9px;
    left: 9px;
    min-width: 30px;
    height: 24px;
    font-size: 0.76rem;
  }

  .state-dot {
    top: 12px;
    right: 12px;
  }

  .player-card h2 {
    font-size: 0.98rem;
  }

  .self-card h2 {
    font-size: 1.2rem;
  }

  .player-status {
    margin-top: 6px;
    font-size: 0.86rem;
  }

  .owner-badge {
    min-height: 22px;
    font-size: 0.72rem;
  }

  .word-slot {
    min-height: 36px;
    margin-top: 8px;
    padding: 5px 9px;
    font-size: 0.92rem;
  }

  .kick-button {
    right: 8px;
    bottom: 8px;
    min-height: 30px;
    padding: 0 10px;
    font-size: 0.78rem;
  }

  .empty-state {
    min-height: 104px;
    padding: 14px;
    font-size: 0.9rem;
  }

  .self-zone {
    margin-bottom: 10px;
  }

  .word-controls {
    bottom: 8px;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 12px 30px rgba(27, 73, 130, 0.2);
  }

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

  .button-row > button {
    width: 100%;
    min-height: 44px;
    font-size: 0.92rem;
  }

  #nextRoundButton {
    grid-column: 1 / -1;
  }

  .hint {
    margin-top: 8px;
    font-size: 0.84rem;
  }
}

@media (max-width: 420px) {
  .app-shell {
    width: min(100% - 12px, 1120px);
  }

  .players-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .round-badge {
    grid-column: 1 / -1;
    justify-content: center;
  }
}
