:root {
  --ink: #262044;
  --purple: #603ac8;
  --purple-dark: #45249a;
  --cream: #fff9e9;
  --red: #e84f55;
  --blue: #2674d8;
  --green: #2b9a66;
  --yellow: #f2bd2f;
  --shadow: 0 10px 0 rgba(49, 31, 99, .18), 0 14px 28px rgba(49, 31, 99, .15);
  font-family: ui-rounded, "Arial Rounded MT Bold", Nunito, system-ui, sans-serif;
  color: var(--ink);
  background: #b8e8fa;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  min-height: 100svh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 10% 15%, rgba(255,255,255,.75) 0 5%, transparent 5.5%),
    linear-gradient(180deg, #b7e9fb 0%, #def5fc 50%, #fff2c9 100%);
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 5px solid #ff8f2f; outline-offset: 3px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.cloud { position: fixed; z-index: -1; width: 160px; height: 46px; border-radius: 50px; background: rgba(255,255,255,.65); filter: blur(1px); }
.cloud::before, .cloud::after { content: ""; position: absolute; background: inherit; border-radius: 50%; }
.cloud::before { width: 70px; height: 70px; left: 22px; bottom: 0; }
.cloud::after { width: 86px; height: 86px; right: 18px; bottom: 0; }
.cloud-one { top: 16%; left: -55px; }
.cloud-two { top: 42%; right: -70px; transform: scale(.75); }
.topbar { height: 68px; padding: max(10px, env(safe-area-inset-top)) 14px 6px; display: grid; grid-template-columns: 56px 1fr 56px; align-items: center; gap: 8px; }
.brand { text-align: center; color: var(--purple-dark); font-weight: 1000; font-size: clamp(19px, 5vw, 27px); letter-spacing: -.5px; }
.brand span { color: #f09b19; }
.icon-button { width: 52px; min-height: 52px; border: 3px solid rgba(69,36,154,.18); border-radius: 18px; color: var(--purple-dark); background: rgba(255,255,255,.82); font-size: 26px; font-weight: 1000; box-shadow: 0 4px 0 rgba(69,36,154,.15); }
.screen { width: min(100%, 900px); min-height: calc(100svh - 68px); margin: auto; padding: 18px max(16px, env(safe-area-inset-left)) max(22px, env(safe-area-inset-bottom)); }
.home-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; padding-top: 4px; }
.hero-mark { display: flex; align-items: center; justify-content: center; height: 112px; margin-bottom: 5px; }
.hero-mark span { width: 78px; height: 98px; margin: 0 -8px; display: grid; place-items: center; border: 6px solid #fff; border-radius: 21px; color: #fff; font-size: 58px; font-weight: 1000; text-shadow: 0 3px rgba(0,0,0,.18); box-shadow: var(--shadow); transform: rotate(-9deg); background: var(--red); }
.hero-mark span:nth-child(2) { background: var(--blue); transform: translateY(-9px) rotate(5deg); }
.hero-mark span:nth-child(3) { background: var(--yellow); color: var(--ink); transform: rotate(11deg); }
h1 { margin: 4px 0; color: var(--purple-dark); font-size: clamp(31px, 8vw, 48px); text-align: center; letter-spacing: -1px; }
.intro { margin: 4px 0 18px; font-size: 18px; font-weight: 700; }
.setup-card { width: min(100%, 440px); padding: 20px; border: 4px solid rgba(255,255,255,.9); border-radius: 28px; background: rgba(255,255,255,.72); box-shadow: var(--shadow); backdrop-filter: blur(8px); }
label { display: block; margin: 0 0 7px 3px; font-weight: 900; }
input { width: 100%; min-height: 60px; border: 3px solid #c2b4e3; border-radius: 17px; padding: 10px 16px; background: #fff; color: var(--ink); font-size: 22px; font-weight: 800; }
input::placeholder { color: #aaa0ba; }
.primary-button, .secondary-button { width: 100%; min-height: 60px; border-radius: 18px; padding: 10px 18px; font-size: 19px; font-weight: 1000; cursor: pointer; }
.primary-button { margin-top: 12px; border: 0; color: #fff; background: linear-gradient(#7049dd, var(--purple)); box-shadow: 0 7px 0 var(--purple-dark); }
.primary-button:active { transform: translateY(4px); box-shadow: 0 3px 0 var(--purple-dark); }
.secondary-button { margin-top: 10px; border: 3px solid var(--purple); color: var(--purple-dark); background: #fff; box-shadow: 0 5px 0 #c8b9e9; }
.or { height: 40px; display: flex; align-items: center; gap: 10px; color: #746b84; font-weight: 800; font-size: 14px; }
.or::before, .or::after { content: ""; height: 2px; flex: 1; background: #d7cfea; }
.room-input { text-align: center; text-transform: uppercase; letter-spacing: .32em; padding-left: calc(16px + .32em); font-size: 28px; }
.error-message { min-height: 18px; margin: 10px 0 0; color: #ad2032; font-weight: 900; text-align: center; }
.waiting-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.waiting-star { color: #f1a620; font-size: 82px; filter: drop-shadow(0 7px 0 #d78212); animation: bob 1.8s ease-in-out infinite; }
.eyebrow { margin: 12px 0 6px; color: var(--purple-dark); text-transform: uppercase; letter-spacing: .15em; font-weight: 1000; }
.big-code { min-height: 86px; border: 4px dashed var(--purple); border-radius: 22px; padding: 8px 18px 8px 28px; color: var(--purple-dark); background: rgba(255,255,255,.82); letter-spacing: .25em; font-size: clamp(44px, 15vw, 72px); font-weight: 1000; box-shadow: var(--shadow); }
.waiting-screen > p:not(.eyebrow):not(.waiting-label) { max-width: 390px; font-size: 18px; font-weight: 750; }
.waiting-screen .primary-button { max-width: 320px; }
.waiting-bubbles { display: flex; gap: 10px; margin-top: 38px; }
.waiting-bubbles i { width: 17px; height: 17px; border-radius: 50%; background: var(--purple); animation: bounce 1.1s infinite; }
.waiting-bubbles i:nth-child(2) { animation-delay: .15s; }
.waiting-bubbles i:nth-child(3) { animation-delay: .3s; }
.waiting-label { font-weight: 900; }
.game-screen { padding-top: 4px; display: flex; flex-direction: column; }
.game-meta { display: flex; justify-content: space-between; align-items: center; min-height: 38px; }
.connection-badge, .room-pill { border: 0; border-radius: 999px; padding: 7px 11px; background: rgba(255,255,255,.75); color: #32654b; font-size: 12px; font-weight: 900; }
.room-pill { min-height: 38px; color: var(--purple-dark); letter-spacing: .12em; }
.turn-banner { align-self: center; min-height: 48px; margin: 2px 0 8px; padding: 10px 23px; border-radius: 999px; display: grid; place-items: center; color: #fff; background: var(--purple); font-size: 20px; font-weight: 1000; box-shadow: 0 5px 0 var(--purple-dark); }
.turn-banner.wait { color: var(--ink); background: #fff; box-shadow: 0 5px 0 #b9d5df; }
.opponent-panel { min-height: 66px; padding: 7px 12px; display: flex; align-items: center; gap: 9px; border: 3px solid rgba(255,255,255,.82); border-radius: 20px; background: rgba(255,255,255,.54); }
.avatar { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--green); font-size: 27px; font-weight: 1000; }
.opponent-panel strong, .opponent-panel span { display: block; }
.opponent-panel span { color: #64717b; font-size: 12px; font-weight: 800; }
.mini-cards { margin-left: auto; display: flex; flex-direction: row-reverse; padding-right: 7px; }
.mini-card { width: 24px; height: 36px; margin-right: -9px; border: 2px solid white; border-radius: 6px; background: repeating-linear-gradient(45deg, var(--purple), var(--purple) 5px, #805fe0 5px, #805fe0 10px); box-shadow: 0 2px 3px #857a9b; }
.table { flex: 1; min-height: 265px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.trail-zone { width: 100%; text-align: center; }
.trail-zone > span, .pile-label { color: #655c72; font-size: 12px; font-weight: 1000; text-transform: uppercase; letter-spacing: .1em; }
.word-trail { min-height: 52px; display: flex; align-items: center; justify-content: center; gap: 5px; font-size: 35px; font-weight: 1000; letter-spacing: .1em; color: var(--purple-dark); }
.word-trail em { font-size: 18px; letter-spacing: 0; font-style: normal; color: #7a7283; }
.trail-letter { width: 42px; height: 46px; display: grid; place-items: center; border-bottom: 5px solid var(--purple); }
.piles { display: flex; align-items: end; justify-content: center; gap: 36px; }
.draw-pile { min-width: 98px; min-height: 130px; padding: 0; border: 0; border-radius: 19px; background: transparent; }
.card-back, .letter-card { width: 98px; height: 130px; border: 6px solid white; border-radius: 19px; display: grid; place-items: center; box-shadow: var(--shadow); }
.card-back { color: #fff; background: repeating-linear-gradient(45deg, var(--purple-dark), var(--purple-dark) 12px, #7049d4 12px, #7049d4 24px); font-size: 45px; font-weight: 1000; line-height: .7; text-shadow: 0 3px rgba(0,0,0,.2); }
.card-back small { font-size: 12px; letter-spacing: .08em; }
.draw-pile:disabled { opacity: .52; filter: grayscale(.4); }
.pile-label { display: block; margin-bottom: 4px; text-align: center; }
.letter-card { position: relative; color: white; font-size: 67px; font-weight: 1000; text-shadow: 0 4px rgba(0,0,0,.25); background: var(--card-color); overflow: hidden; }
.letter-card::before { content: ""; position: absolute; inset: 8px; border: 3px solid rgba(255,255,255,.65); border-radius: 38% 62% 45% 55%; transform: rotate(-12deg); }
.letter-card::after { content: attr(data-color); position: absolute; bottom: 7px; font-size: 9px; text-transform: uppercase; letter-spacing: .08em; text-shadow: none; color: rgba(255,255,255,.95); }
.letter-card span { position: relative; z-index: 1; }
.letter-card[data-color="yellow"] { color: var(--ink); text-shadow: 0 3px rgba(255,255,255,.45); }
.letter-card[data-color="yellow"]::after { color: var(--ink); }
.letter-card[data-color="red"] { --card-color: var(--red); }
.letter-card[data-color="blue"] { --card-color: var(--blue); }
.letter-card[data-color="green"] { --card-color: var(--green); }
.letter-card[data-color="yellow"] { --card-color: var(--yellow); }
.hand-zone { margin: auto -16px calc(-22px - env(safe-area-inset-bottom)); padding: 9px 14px max(16px, env(safe-area-inset-bottom)); border-radius: 27px 27px 0 0; background: rgba(255,255,255,.78); box-shadow: 0 -6px 20px rgba(55,38,91,.1); }
.hand-heading { max-width: 870px; margin: 0 auto 5px; display: flex; justify-content: space-between; font-size: 14px; }
.hand { min-height: 145px; display: flex; gap: 8px; overflow-x: auto; overscroll-behavior-x: contain; padding: 4px 8px 12px; scroll-snap-type: x proximity; }
.hand .letter-card { flex: 0 0 91px; width: 91px; height: 124px; border-width: 5px; scroll-snap-align: center; cursor: pointer; }
.hand .letter-card:disabled { opacity: .64; filter: saturate(.62); cursor: default; }
.hand .letter-card:not(:disabled):hover { transform: translateY(-5px) rotate(-1deg); }
.error-toast { position: fixed; z-index: 8; left: 50%; bottom: calc(175px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: 90%; margin: 0; padding: 10px 15px; border-radius: 13px; color: #fff; background: #a72f40; font-weight: 900; box-shadow: 0 5px 12px rgba(0,0,0,.2); opacity: 0; pointer-events: none; transition: opacity .2s; }
.error-toast.show { opacity: 1; }
.celebration { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(50,31,95,.72); backdrop-filter: blur(5px); }
.celebration-card { width: min(100%, 430px); padding: 25px; border: 6px solid white; border-radius: 31px; text-align: center; background: var(--cream); box-shadow: 0 14px 0 #3d2182; animation: pop .35s both; }
.celebration-icon { display: block; color: #efa419; font-size: 68px; line-height: 1; }
.celebration h2 { margin: 6px; color: var(--purple-dark); font-size: 34px; }
.celebration p { font-size: 22px; font-weight: 900; }
.confetti { position: fixed; inset: 8% 0 auto; color: #ffce31; text-align: center; word-spacing: 10vw; font-size: 30px; }
dialog { width: min(calc(100% - 28px), 540px); border: 5px solid white; border-radius: 28px; padding: 24px; color: var(--ink); background: var(--cream); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(42,27,78,.65); backdrop-filter: blur(4px); }
dialog h2 { margin: 4px 0 18px; color: var(--purple-dark); font-size: 32px; }
.close-button { position: absolute; right: 13px; top: 12px; width: 50px; height: 50px; border: 0; border-radius: 50%; color: var(--purple-dark); background: #e9e0fa; font-size: 34px; }
.how-list { list-style: none; padding: 0; display: grid; gap: 12px; }
.how-list li { display: flex; align-items: center; gap: 12px; font-size: 17px; font-weight: 700; }
.how-list b { flex: 0 0 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--purple); font-size: 23px; }
.example-word { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin: 20px 0; }
.example-word i { width: 43px; height: 54px; display: grid; place-items: center; border-radius: 9px; color: white; background: var(--red); font-size: 27px; font-style: normal; font-weight: 1000; }
.example-word i:nth-of-type(even) { background: var(--blue); }
.example-word strong { width: 100%; margin-top: 6px; text-align: center; color: var(--purple-dark); font-size: 20px; }
.adult-note { padding: 13px; border-radius: 14px; background: #e9f6fa; line-height: 1.45; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-12px); } }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-5deg); } 50% { transform: translateY(-10px) rotate(5deg); } }
@keyframes pop { from { transform: scale(.65) rotate(-3deg); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (min-width: 700px) and (orientation: landscape) {
  .game-screen { display: grid; grid-template-columns: 1fr 1.6fr; grid-template-rows: auto auto 1fr auto; gap: 8px 28px; }
  .game-meta { grid-column: 1 / -1; }
  .turn-banner { grid-column: 1 / -1; }
  .opponent-panel { grid-column: 1; }
  .table { grid-column: 1; min-height: 310px; }
  .hand-zone { grid-column: 2; grid-row: 3 / 5; margin: 0; border-radius: 28px; align-self: stretch; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
  .hand { flex-wrap: wrap; justify-content: center; align-content: center; overflow-y: auto; }
  .hand .letter-card { flex-basis: 105px; width: 105px; height: 142px; }
}
@media (max-height: 690px) {
  .table { min-height: 225px; }
  .topbar { height: 60px; }
  .screen { min-height: calc(100svh - 60px); }
  .hero-mark { transform: scale(.78); height: 83px; }
  .home-screen h1 { font-size: 30px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
