body > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: 62px;
  padding: 8px clamp(12px, 3vw, 44px) !important;
  border: 0 !important;
  border-bottom: 1.5px solid rgba(164, 128, 95, .14) !important;
  background: rgba(255, 252, 245, .9) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.95), 0 6px 22px rgba(96, 67, 45, .08);
  backdrop-filter: blur(18px);
}

body > header > div:first-child > div:first-child {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px !important;
  height: 42px !important;
  border: 2px solid #fffdf9 !important;
  border-radius: 16px !important;
  color: #fff8ef;
  background: linear-gradient(155deg, #ffd1dc, #f4a4b8) !important;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.65), 0 4px 0 #d6859b, 0 8px 16px rgba(217, 107, 132, .2) !important;
}
body > header h1 { font-family: var(--font-display); color: var(--cocoa-700) !important; letter-spacing: .01em; }
body > header button {
  border-radius: 14px !important;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.8), inset 0 -2px 0 rgba(160,110,80,.12), 0 3px 0 rgba(170,120,90,.22), 0 6px 12px rgba(72,49,34,.08);
  transition: transform .15s, box-shadow .15s;
}
body > header button:hover:not(:disabled) { transform: translateY(-1px); }
body > header button:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 1px 0 rgba(170,120,90,.22); }
body > header > div:first-child, body > header > div:last-child { display: flex; align-items: center; gap: 8px; }
@media (max-width: 940px) and (min-width: 640px) {
  body > header { padding-inline: 14px !important; }
  body > header > div:last-child { gap: 5px !important; }
  body > header button { padding: 5px 8px !important; font-size: 11px !important; }
  #music-label, #nav-room-badge { display: none !important; }
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(100%, 1480px) !important;
  max-width: none !important;
  min-height: calc(100dvh - 66px);
  margin-inline: auto;
  padding: clamp(14px, 3vw, 42px) clamp(12px, 3vw, 44px) 34px !important;
  justify-content: flex-start !important;
}

#view-setup, #view-lobby {
  width: min(100%, 1120px) !important;
  max-width: 1120px !important;
  border: 1px solid rgba(122, 89, 63, .16) !important;
  border-radius: var(--radius-lg) !important;
  background: var(--surface) !important;
  box-shadow: var(--shadow-raised) !important;
  backdrop-filter: blur(14px);
  animation: pageIn calc(var(--motion-slow) * var(--motion-duration)) ease both;
}
#view-setup, #view-lobby { background: linear-gradient(180deg, rgba(255,253,247,.96), rgba(251,243,230,.94)) !important; }

#view-setup { position: relative; overflow: hidden; padding: clamp(22px, 4vw, 50px) !important; }
#view-setup:not(.hidden) { display: grid !important; grid-template-columns: minmax(0, .85fr) minmax(360px, 1.15fr); gap: 20px clamp(24px, 4vw, 52px); align-items: start; }
#view-setup::before {
  position: absolute;
  top: 0;
  right: 0;
  width: min(42%, 420px);
  height: 190px;
  content: '';
  pointer-events: none;
  background:
    radial-gradient(ellipse at 65% 0%, rgba(243, 181, 167, .34), transparent 63%),
    radial-gradient(ellipse at 80% 55%, rgba(178, 207, 181, .32), transparent 65%);
}
#view-setup > .welcome-hero { position: relative; z-index: 1; grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 34%); align-items: center; gap: 16px; margin: 0 0 4px !important; text-align: left !important; }
.welcome-copy { grid-column: 1; grid-row: 1; }
.welcome-kicker { display: block; margin-bottom: 12px; color: var(--gold-500); font-family: var(--font-display); font-size: 12px; font-weight: 700; letter-spacing: .14em; line-height: 1.45; }
.welcome-copy h2 { max-width: 620px; margin: 0; padding-top: 4px; font-size: clamp(28px, 3.8vw, 44px) !important; line-height: 1.42 !important; }
.welcome-copy p { margin-top: 10px !important; color: var(--muted) !important; font-size: 15px !important; line-height: 1.55; }
.welcome-cat { grid-column: 2; grid-row: 1 / span 2; align-self: end; justify-self: end; width: min(100%, 300px); height: auto; margin: -4px 2px -10px 0; filter: drop-shadow(0 12px 12px rgba(67, 48, 33, .12)); }
#view-setup > .welcome-hero > .mt-2 { grid-column: 1; grid-row: 2; justify-content: flex-start !important; margin-top: 10px !important; }
#view-setup > .mb-4 { grid-column: 1; grid-row: 2; align-self: start; margin: 14px 0 0 !important; }
#view-setup > .mb-6 { grid-column: 2; grid-row: 2; margin: 14px 0 0 !important; }
#view-setup > .space-y-3 { grid-column: 1 / -1; width: 100%; margin-top: 8px; }
#view-setup > .mb-4 > label, #view-setup > .mb-6 label { color: var(--cocoa-500) !important; letter-spacing: .06em; }
#view-setup > .mb-4 input { min-height: 58px; font-size: 18px !important; font-weight: 600; }
#view-setup > .welcome-hero > .mt-2 #cloud-status-pill { padding: 6px 12px !important; }
#view-setup h2 { font-family: var(--font-display); color: var(--cocoa-700) !important; }
#view-lobby h2 { font-family: var(--font-display); color: var(--cocoa-700) !important; font-size: clamp(20px, 2.5vw, 28px) !important; line-height: 1.45 !important; padding-top: 2px; text-wrap: balance; word-break: keep-all; }
#view-setup > .mb-4, #view-setup > .mb-6, #view-setup > .space-y-3 { position: relative; z-index: 1; }
#view-setup input, #view-setup select { min-height: 48px; border-radius: 15px !important; border-color: #deccb7 !important; background: #fffdf8 !important; }
#view-setup input:focus { border-color: var(--gold-500) !important; box-shadow: 0 0 0 4px rgba(185, 139, 69, .12); }
#view-setup #avatar-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px !important; }
#view-setup #avatar-grid button { min-height: 98px; padding: 8px 6px !important; border-radius: 19px !important; background: #fffaf1; transition: transform var(--motion-base), box-shadow var(--motion-base); }
#view-setup #avatar-grid button:hover { transform: translateY(-3px) rotate(-1.5deg); box-shadow: var(--shadow-card); }
.avatar-option__label { white-space: normal; word-break: keep-all; overflow-wrap: break-word; line-height: 1.4; }

#view-lobby { padding: clamp(16px, 3vw, 34px) !important; }
#view-lobby > div:first-child { border-color: var(--cream-200) !important; }
#lobby-seats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px !important; }
#lobby-seats-grid .lobby-seat { min-height: 156px; justify-content: center; border-radius: 22px !important; border-width: 1px !important; background: linear-gradient(155deg, #fffefa, #f8f0e4) !important; box-shadow: 0 5px 16px rgba(72,49,34,.07); transition: transform var(--motion-base), box-shadow var(--motion-base); }
#lobby-seats-grid .lobby-seat--occupied { border-color: rgba(142, 105, 72, .25) !important; }
#lobby-seats-grid .lobby-seat--bot { background: linear-gradient(155deg, #f7f8ed, #edf1df) !important; }
#lobby-seats-grid .lobby-seat--empty { border-color: rgba(122, 101, 82, .26) !important; background: rgba(246, 240, 230, .55) !important; }
#lobby-seats-grid .lobby-seat:hover { transform: translateY(-3px); box-shadow: var(--shadow-card); }
.lobby-seat__avatar { width: 72px !important; height: 72px !important; border-radius: 999px !important; overflow: hidden; border: 3px solid #fffdf9 !important; box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 6px 15px rgba(68,48,33,.12); }
.lobby-seat__name { max-width: 100%; margin-top: 4px; font-size: 14px !important; }
.seat-state { letter-spacing: .03em; }

#my-hand-container { scroll-padding-inline: 16px; }
body.game-screen { min-height: var(--app-viewport-height, 100dvh); }
body.game-screen > header { min-height: 52px; padding-block: 4px !important; }
body.game-screen main { flex: 1 1 auto; display: flex; flex-direction: column; align-items: stretch; width: 100% !important; max-width: none !important; min-height: 0 !important; margin: 0 !important; padding: 0 !important; overflow: visible; }
body.game-screen #view-game { position: relative; isolation: isolate; display: flex; flex-direction: column; justify-content: flex-start; flex: 1 1 auto; width: 100%; min-height: 0; gap: 0 !important; overflow-x: clip; }
body.game-screen #view-game > div:first-child { position: relative; z-index: 5; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; width: min(calc(100% - 24px), 1080px) !important; margin: 10px auto 0; padding: 6px 10px 6px 12px !important; border: 1.5px solid rgba(255,255,255,.72) !important; border-radius: 999px !important; background: rgba(255,250,242,.74) !important; backdrop-filter: blur(14px) saturate(1.15); -webkit-backdrop-filter: blur(14px) saturate(1.15); box-shadow: inset 0 1px 0 rgba(255,255,255,.9), 0 4px 0 rgba(150,110,78,.14), 0 12px 26px rgba(72,49,34,.14) !important; }
#game-mode-pill, #game-deck-pill, #round-badge { line-height: 1.4; box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 2px 0 rgba(150,110,78,.14); }
#turn-banner { padding: 4px 12px; border-radius: 999px; background: linear-gradient(180deg,#fff7e2,#ffe9bd); color: #6b4914 !important; line-height: 1.4; box-shadow: inset 0 1px 0 rgba(255,255,255,.85), 0 2px 0 rgba(196,150,70,.25); }

#result-modal, #club-panel, #confirm-leave-modal, #auto-test-modal { padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
#result-modal > div, #club-panel > div { max-height: min(90dvh, 900px); border: 1px solid rgba(122, 89, 63, .18) !important; border-radius: 28px !important; box-shadow: 0 28px 90px rgba(35, 25, 19, .3) !important; }

@media (max-width: 700px) {
  main { min-height: calc(100dvh - 54px); padding: 12px 10px calc(20px + env(safe-area-inset-bottom)) !important; }
  body > header { min-height: 54px; padding-inline: 10px !important; }
  body > header button { min-height: 36px; }
  #view-setup { padding: 20px 16px !important; }
  #view-setup:not(.hidden) { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  #view-setup::before { width: 70%; height: 125px; }
  #view-setup > .welcome-hero { grid-template-columns: minmax(0, 1fr) 120px; gap: 4px; margin-bottom: 0 !important; }
  .welcome-kicker { font-size: 9px; letter-spacing: .1em; }
  .welcome-copy h2 { font-size: clamp(23px, 6.5vw, 32px) !important; line-height: 1.4 !important; }
  .welcome-copy p { max-width: 230px; font-size: 12px !important; }
  .welcome-cat { width: 130px; margin: 0 -12px -5px 0; }
  #view-setup > .welcome-hero > .mt-2 { grid-column: 1 / -1; grid-row: 2; margin-top: 2px !important; }
  #view-setup > .mb-4, #view-setup > .mb-6 { grid-column: 1; grid-row: auto; margin: 0 !important; }
  #view-setup > .mb-6 { grid-column: 1; }
  #view-setup > .space-y-3 { grid-column: 1; margin-top: 0; }
  #view-setup #avatar-grid button { min-height: 92px; padding: 7px 4px !important; }
  #view-setup #avatar-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px !important; }
  #view-lobby { padding: 15px 12px !important; }
  #view-lobby h2 { font-size: 19px !important; line-height: 1.45 !important; }
  #btn-deck-1 > div:last-child > div:first-child, #btn-deck-2 > div:last-child > div:first-child { flex-wrap: wrap; gap: 4px; }
  #lobby-seats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px !important; }
  body.game-screen #view-game > div:first-child { width: calc(100% - 14px) !important; margin-top: 5px; border-radius: 16px !important; padding: 4px 8px !important; gap: 4px !important; }
  body.game-screen #game-mode-pill, body.game-screen #game-deck-pill, body.game-screen #round-badge { padding: 2px 7px !important; font-size: 10px !important; }
  body.game-screen #turn-banner { padding: 2px 8px !important; font-size: 10.5px !important; }
  #my-hand-container { margin-inline: 0; padding-inline: 4px; overflow-x: hidden; }
  #my-player-badge { max-width: 100%; }
  #my-action-buttons { justify-content: flex-end; }
}

@media (max-width: 460px) {
  body > header { padding-inline: 7px !important; }
  body > header > div:first-child { gap: 5px !important; }
  body > header > div:first-child > div:first-child { width: 32px !important; height: 32px !important; font-size: 16px !important; border-radius: 11px !important; }
  body > header > div:last-child { gap: 3px !important; }
  body > header button { min-height: 34px; padding: 4px 6px !important; font-size: 11px !important; border-radius: 10px !important; }
  #auto-verify-badge-text { display: none; }
  #nav-room-badge { display: none !important; }
  #lobby-seats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px !important; }
  #lobby-seats-grid .lobby-seat { min-height: 126px; padding: 8px !important; }
  .lobby-seat__avatar { width: 58px !important; height: 58px !important; }
}

@media (max-height: 620px) and (orientation: landscape) {
  body.game-screen #view-game > div:first-child { margin-top: 4px; padding-block: 3px !important; }
  #my-hand-container { min-height: 105px !important; padding-top: 20px !important; padding-bottom: 8px !important; }
}
