:root {
  color-scheme: light;
  --paper: #f5f1e8;
  --surface: #fffdf7;
  --ink: #1f201b;
  --muted: #6d6b61;
  --line: #292a25;
  --coral: #f05a40;
  --yellow: #f7d24e;
  --blue: #637ce8;
  --green: #c9e36f;
  --shadow: 4px 5px 0 var(--ink);
  font-family: ui-rounded, "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(#1f201b0b 0.7px, transparent 0.7px);
  background-size: 7px 7px;
}

button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
button:disabled { cursor: not-allowed; opacity: .55; }
a { color: inherit; }

.shell { width: min(1120px, calc(100% - 40px)); margin-inline: auto; }
.topbar { min-height: 76px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1.5px solid #1f201b30; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-size: 1.14rem; font-weight: 1000; letter-spacing: -.055em; }
.brand img { width: 42px; height: 42px; }
.brand em { color: var(--coral); font-style: normal; }
.top-note, .eyebrow, .micro-label { font-size: .77rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.top-note { color: var(--muted); }
.home-main { padding-block: clamp(30px, 6vw, 74px) 42px; }
.hero { display: grid; grid-template-columns: 1.05fr .95fr; gap: clamp(30px, 5vw, 72px); align-items: center; margin-bottom: 35px; }
.hero-art { position: relative; min-height: 295px; overflow: hidden; border: 2px solid var(--line); border-radius: 30px 30px 26px 30px; background: var(--yellow); box-shadow: var(--shadow); isolation: isolate; }
.hero-art::before, .hero-art::after { position: absolute; content: ""; border: 2px solid var(--line); border-radius: 50%; }
.hero-art::before { width: 180px; height: 180px; top: -70px; right: -35px; background: var(--coral); }
.hero-art::after { width: 18px; height: 18px; top: 27px; left: 29px; background: var(--blue); box-shadow: 30px 17px 0 -3px var(--green), 64px -3px 0 -5px var(--coral); }
.hero-art-word { position: absolute; top: 28px; right: 26px; z-index: 1; transform: rotate(7deg); font-size: .8rem; font-weight: 950; letter-spacing: .13em; }
.hero-meme { position: absolute; width: min(68%, 302px); aspect-ratio: 1; left: 50%; top: 52%; transform: translate(-50%, -43%) rotate(-3deg); overflow: hidden; border: 2px solid var(--line); border-radius: 14px; background: #ff8e72; box-shadow: 8px 8px 0 #1f201b; }
.hero-meme svg { display: block; width: 100%; height: 100%; }
.hero-caption { position: absolute; left: 8%; right: 8%; z-index: 2; color: #fff9eb; font-weight: 1000; font-size: clamp(.8rem, 2vw, 1.18rem); line-height: 1.12; text-align: center; text-transform: uppercase; text-shadow: -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink); }
.hero-caption.top { top: 9%; }
.hero-caption.bottom { bottom: 9%; }
.spark { position: absolute; z-index: 3; font-size: 2.5rem; font-weight: 1000; }
.spark.one { bottom: 24px; left: 24px; color: var(--coral); transform: rotate(-12deg); }
.spark.two { right: 25px; bottom: 23px; color: var(--blue); transform: rotate(17deg); }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; color: #514f48; }
.eyebrow::before { width: 9px; height: 9px; border-radius: 50%; background: var(--coral); content: ""; }
h1, h2, h3, p { margin-top: 0; }
.hero h1 { max-width: 570px; margin: 17px 0 17px; font-size: clamp(2.8rem, 6.2vw, 5rem); font-weight: 1000; line-height: .92; letter-spacing: -.085em; }
.hero h1 span { color: var(--coral); }
.hero-copy { max-width: 460px; margin-bottom: 0; color: #59574f; font-size: clamp(1rem, 1.5vw, 1.12rem); line-height: 1.55; }
.entry-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.panel { padding: clamp(22px, 3vw, 32px); border: 1.5px solid var(--line); border-radius: 19px; background: var(--surface); box-shadow: 3px 4px 0 #1f201b20; }
.panel.create-panel { background: #fff6d6; }
.panel-heading { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 21px; }
.panel-heading h2 { margin: 7px 0 0; font-size: clamp(1.4rem, 2.3vw, 1.9rem); line-height: 1.05; letter-spacing: -.06em; }
.resume-row { margin-top: 16px; }
.join-panel { max-width: 550px; margin: 32px auto; }
.join-heading { margin: 8px 0 0; font-size: clamp(2.2rem, 6vw, 3.4rem); letter-spacing: -.07em; }
.join-intro { margin-bottom: 20px; }
.privacy-hint { margin-top: 15px; }
.new-round-form { margin-top: 16px; }
.number-badge { display: grid; width: 37px; height: 37px; flex: 0 0 37px; place-items: center; border: 1.5px solid var(--line); border-radius: 50%; background: var(--green); font-weight: 950; }
.field { display: grid; gap: 7px; margin-bottom: 15px; }
.field label { font-size: .88rem; font-weight: 800; }
.field input, .field select { width: 100%; min-height: 49px; padding: 11px 13px; border: 1.5px solid #37383260; border-radius: 10px; background: white; color: var(--ink); }
.field input::placeholder { color: #929087; }
.field-hint { margin: -1px 0 0; color: var(--muted); font-size: .85rem; line-height: 1.4; }
.button { display: inline-flex; min-height: 47px; align-items: center; justify-content: center; gap: 9px; padding: 11px 17px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--ink); color: white; cursor: pointer; font-weight: 900; text-decoration: none; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 3px 0 #1f201b50; }
.button.primary { width: 100%; background: var(--coral); color: #1f201b; }
.button.yellow { background: var(--yellow); color: var(--ink); }
.button.ghost { background: transparent; color: var(--ink); }
.button.small { min-height: 40px; padding: 8px 12px; font-size: .9rem; }
.button.danger { border-color: #a62920; color: #9d291f; }
.privacy { margin-top: 25px; color: var(--muted); font-size: .86rem; line-height: 1.55; }
.privacy summary { width: fit-content; cursor: pointer; font-weight: 750; }
.privacy p { max-width: 780px; margin: 9px 0; }
.footer { display: flex; justify-content: space-between; gap: 16px; padding-block: 17px 26px; border-top: 1px solid #1f201b30; color: var(--muted); font-size: .83rem; }
.toast { margin: 0 0 18px; padding: 12px 14px; border: 1.5px solid var(--coral); border-radius: 10px; background: #fff0ec; color: #8c2c1f; font-size: .95rem; font-weight: 750; }
.room-main { padding-block: 28px 42px; }
.room-heading { display: flex; justify-content: space-between; align-items: start; gap: 18px; margin-bottom: 22px; }
.room-heading h1 { margin: 7px 0 5px; font-size: clamp(2rem, 4vw, 3.5rem); line-height: 1; letter-spacing: -.075em; }
.room-heading p { margin-bottom: 0; color: var(--muted); }
.room-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.room-info { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: center; margin-bottom: 19px; padding: 15px 18px; border: 1.5px solid var(--line); border-radius: 13px; background: var(--surface); }
.player-list { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.player-list .micro-label { margin-right: 3px; color: var(--muted); font-size: .7rem; }
.player-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid #1f201b2b; border-radius: 999px; background: #f4f0e8; font-size: .87rem; font-weight: 750; }
.player-chip.host::after { content: "★"; color: #bc6b04; }
.round-count { white-space: nowrap; color: var(--muted); font-size: .87rem; font-weight: 750; }
.game-panel { padding: clamp(21px, 3.4vw, 35px); border: 1.5px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.game-top { display: flex; justify-content: space-between; align-items: start; gap: 18px; padding-bottom: 20px; border-bottom: 1px solid #1f201b26; }
.game-top h2 { margin: 7px 0 5px; font-size: clamp(1.8rem, 3.6vw, 2.7rem); letter-spacing: -.07em; line-height: 1.02; }
.game-top p { margin-bottom: 0; color: var(--muted); }
.phase-tag { flex: 0 0 auto; padding: 7px 10px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--green); font-size: .75rem; font-weight: 950; letter-spacing: .05em; text-transform: uppercase; }
.phase-tag.voting { background: var(--yellow); }
.phase-tag.results { background: #ddd9ff; }
.game-content { padding-top: 23px; }
.creator-grid { display: grid; grid-template-columns: minmax(0, .93fr) minmax(280px, 1.07fr); gap: clamp(20px, 4vw, 46px); align-items: start; }
.template-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin: 9px 0 19px; }
.template-choice { overflow: hidden; padding: 0; border: 1.5px solid #1f201b5d; border-radius: 9px; background: white; cursor: pointer; text-align: center; }
.template-choice[aria-pressed="true"] { outline: 3px solid var(--coral); outline-offset: 2px; border-color: var(--ink); }
.template-choice svg { display: block; width: 100%; aspect-ratio: 1; }
.template-choice span { display: block; overflow: hidden; padding: 5px 2px 6px; font-size: .75rem; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.caption-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.creator-preview { position: sticky; top: 18px; }
.meme-card { position: relative; overflow: hidden; width: min(100%, 435px); aspect-ratio: 1; margin-inline: auto; border: 1.5px solid var(--line); border-radius: 13px; background: #ff987a; box-shadow: 4px 5px 0 #1f201b18; }
.meme-art, .meme-art svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.caption { position: absolute; z-index: 1; left: 5%; right: 5%; overflow: hidden; color: #fff9ee; font-size: clamp(1.2rem, 3.2vw, 2.15rem); font-weight: 1000; line-height: 1.04; text-align: center; text-shadow: -2px -2px 0 #1f201b, 2px -2px 0 #1f201b, -2px 2px 0 #1f201b, 2px 2px 0 #1f201b, 0 3px 0 #1f201b; text-transform: uppercase; overflow-wrap: anywhere; }
.caption.top { top: 5%; max-height: 31%; }
.caption.bottom { bottom: 5%; max-height: 31%; }
.meme-author { margin: 10px 0 0; color: var(--muted); font-size: .9rem; text-align: center; }
.creator-actions { margin-top: 14px; }
.waiting-card { display: flex; min-height: 108px; align-items: center; gap: 15px; padding: 17px 19px; border: 1.5px dashed #1f201b65; border-radius: 13px; background: #fbf7e9; }
.waiting-icon { display: grid; width: 42px; height: 42px; flex: 0 0 42px; place-items: center; border: 1.5px solid var(--line); border-radius: 50%; background: var(--yellow); font-size: 1.35rem; }
.waiting-card p { margin: 3px 0 0; color: var(--muted); line-height: 1.45; }
.vote-grid, .result-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.vote-item, .result-item { min-width: 0; padding: 13px; border: 1.5px solid #1f201b40; border-radius: 13px; background: #f8f5ed; }
.vote-item.selected, .result-item.winner { border: 2px solid var(--ink); background: #f4e8ad; box-shadow: 3px 3px 0 var(--ink); }
.vote-item .meme-card, .result-item .meme-card { width: 100%; }
.vote-item .caption, .result-item .caption { font-size: clamp(1rem, 2vw, 1.55rem); }
.vote-action { width: 100%; margin-top: 12px; }
.result-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 11px 2px 0; font-size: .91rem; }
.vote-total { padding: 5px 9px; border: 1px solid var(--line); border-radius: 99px; background: white; font-weight: 900; white-space: nowrap; }
.winner-banner { margin-bottom: 20px; padding: 18px 20px; border: 1.5px solid var(--line); border-radius: 13px; background: var(--yellow); text-align: center; }
.winner-banner h3 { margin: 5px 0 4px; font-size: clamp(1.6rem, 3vw, 2.3rem); letter-spacing: -.05em; }
.winner-banner p { margin-bottom: 0; color: #51451d; }
.host-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 11px; margin-top: 18px; }
.host-controls .new-round-form { flex: 0 0 100%; }
.host-controls .button { width: auto; }
.host-note { color: var(--muted); font-size: .91rem; }
.history { margin-top: 27px; }
.history h3 { margin-bottom: 11px; font-size: 1rem; }
.history-list { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; list-style: none; }
.history-list li { padding: 7px 10px; border: 1px solid #1f201b32; border-radius: 9px; background: #f5f1e8; color: #55534d; font-size: .85rem; }
.empty { padding: 26px; border: 1.5px dashed #1f201b5d; border-radius: 12px; color: var(--muted); text-align: center; }
.room-privacy { margin-top: 23px; }
.loading { display: grid; min-height: 65vh; place-content: center; text-align: center; }
.loading-mark { width: 58px; height: 58px; margin: 0 auto 15px; animation: bob 1.3s ease-in-out infinite; }
.loading p { color: var(--muted); }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-5deg); } }

@media (max-width: 760px) {
  .shell { width: min(100% - 28px, 600px); }
  .topbar { min-height: 65px; }
  .top-note { max-width: 130px; font-size: .66rem; text-align: right; }
  .hero { grid-template-columns: 1fr; gap: 27px; }
  .hero-copy-block { order: 0; }
  .hero-art { order: 1; min-height: 270px; }
  .hero h1 { max-width: 530px; font-size: clamp(3.05rem, 12vw, 4.5rem); }
  .entry-grid { grid-template-columns: 1fr; gap: 15px; }
  .room-heading { display: block; }
  .room-actions { justify-content: flex-start; margin-top: 15px; }
  .room-info { grid-template-columns: 1fr; gap: 11px; }
  .round-count { white-space: normal; }
  .creator-grid { grid-template-columns: 1fr; }
  .creator-preview { position: static; grid-row: 1; }
  .creator-fields { grid-row: 2; }
  .creator-preview .meme-card { width: min(100%, 365px); }
  .vote-grid, .result-grid { gap: 10px; }
  .vote-item, .result-item { padding: 8px; }
  .vote-item .caption, .result-item .caption { font-size: clamp(.95rem, 3.6vw, 1.5rem); }
  .vote-total { font-size: .8rem; }
  .footer { flex-direction: column; gap: 5px; }
}

@media (max-width: 390px) {
  .template-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .caption-fields { grid-template-columns: 1fr; gap: 0; }
  .phase-tag { font-size: .67rem; }
  .game-top { gap: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
