/*
 * Layout and components. Uses only the variables in theme.css.
 * TODO(design): restyle freely; keep class names or update them in src/views/*.tsx and src/routes/*.tsx.
 */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 18px 18px, rgba(255, 182, 203, 0.55) 2.5px, transparent 3px),
    radial-gradient(circle at 58px 48px, rgba(255, 255, 255, 0.9) 2px, transparent 2.5px),
    linear-gradient(180deg, #fff7fb 0%, #fff0f5 40%, #ffe8f1 100%);
  background-size: 72px 72px, 72px 72px, auto;
  line-height: 1.55;
  font-size: 16px;
}
h1, h2, h3 { font-family: var(--font-heading); line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75em; }
a { color: var(--accent); }
img { max-width: 100%; }
blockquote { margin: 0 0 0.4em; font-size: 1.05rem; }
.skip-link { position: absolute; left: -999px; }
.skip-link:focus { left: 8px; top: 8px; background: var(--surface); padding: 6px 10px; z-index: 10; }

.container { max-width: var(--container); margin: 0 auto; padding: 0 var(--space); }
.main { padding-top: 24px; padding-bottom: 48px; min-height: 70vh; }
@media (max-width: 520px) {
  .container { padding: 0 12px; }
  .main { padding-top: 16px; padding-bottom: 36px; }
  .narrow { max-width: none; margin-left: 0; margin-right: 0; }
  .card { padding: 14px; }
  .page-head { margin-bottom: 14px; gap: 10px; }
  .page-head h1 { font-size: 1.45rem; }
  .btn { min-height: 40px; padding: 10px 14px; }
  .site-nav a { min-height: 44px; }
}

/* Header */
.site-header {
  background: var(--header-bg);
  color: var(--header-text);
  border-bottom: 3px solid var(--accent);
  box-shadow: 0 6px 18px rgba(255, 107, 157, 0.08);
  position: sticky;
  top: 0;
  z-index: 30;
}
.header-inner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "brand nav user";
  align-items: center;
  gap: 10px 14px;
  min-height: 64px;
  padding-top: 8px;
  padding-bottom: 8px;
}
.brand {
  grid-area: brand;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--accent);
  white-space: nowrap;
  min-width: 0;
}
.brand-text { overflow: hidden; text-overflow: ellipsis; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  border: 2px solid var(--bow);
  overflow: hidden;
  flex: 0 0 auto;
}
.brand-mark .emote { width: 1.55rem; height: 1.55rem; }

/* Hello Kitty sticker emotes */
.emote {
  display: inline-block;
  width: 1.35rem;
  height: 1.35rem;
  object-fit: contain;
  vertical-align: -0.25em;
  flex: 0 0 auto;
}
.emote-sm { width: 1.15rem; height: 1.15rem; }
.emote-md { width: 1.45rem; height: 1.45rem; }
.emote-lg { width: 1.75rem; height: 1.75rem; }
.emote-xl { width: 2.5rem; height: 2.5rem; }
.footer-emotes { display: inline-flex; align-items: center; gap: 6px; }
.card > h2 .emote { margin-right: 4px; }
.site-nav {
  grid-area: nav;
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: nowrap;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
  padding: 2px;
}
.site-nav a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  color: var(--text);
  padding: 6px 9px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.86rem;
  white-space: nowrap;
  flex: 0 0 auto;
}
.site-nav a:hover { background: var(--accent-soft); color: var(--bow); }
.site-nav a.active { background: var(--accent); color: var(--accent-contrast); }
.header-user {
  grid-area: user;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
}
.header-user a { color: var(--text); text-decoration: none; }
.header-user a:hover { color: var(--bow); }
.header-name { color: var(--bow) !important; }
.site-header .btn-link { color: var(--accent); font-weight: 700; text-decoration: none; }
.site-header .btn-link:hover { color: var(--bow); }
.site-header .btn { border-radius: var(--radius-pill); }
.nav-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.nav-toggle-label { display: none; }

@media (max-width: 1100px) {
  .site-nav a { padding: 6px 8px; font-size: 0.82rem; }
  .brand-text { font-size: 0.95rem; }
}

.nav-mobile-auth { display: none; }

@media (max-width: 960px) {
  .header-inner {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand toggle"
      "nav nav";
    gap: 8px 10px;
  }
  .header-inner:has(.header-user[data-authed]) {
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas:
      "brand user toggle"
      "nav nav nav";
  }
  .nav-toggle-label {
    grid-area: toggle;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 7px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--accent-soft);
    color: var(--bow);
    font-weight: 800;
    font-size: 0.85rem;
    white-space: nowrap;
  }
  .site-nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    overflow: visible;
    padding: 8px 0 4px;
    border-top: 2px dashed var(--border);
  }
  .site-header:has(.nav-toggle:checked) .site-nav { display: flex; }
  .site-nav a {
    border-radius: var(--radius-small);
    font-size: 1rem;
    padding: 10px 12px;
  }
  .header-desktop-only { display: none !important; }
  .header-user:not([data-authed]) { display: none; }
  .header-user[data-authed] { gap: 4px; }
  .header-name { display: none; }
  .brand-text { max-width: none; }
  .nav-mobile-auth {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding-top: 12px;
    border-top: 2px dashed var(--border);
  }
}

.site-footer {
  border-top: 2px dashed var(--border);
  padding: 22px 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.75);
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  text-align: center;
}

/* Notifications */
.notif { position: relative; }
.notif-bell { text-decoration: none; position: relative; display: inline-block; padding: 4px; }
.notif-count { position: absolute; top: -4px; right: -8px; background: var(--danger); color: #fff; border-radius: 999px; font-size: 0.7rem; padding: 0 6px; line-height: 1.5; }
.notif-panel { position: absolute; right: 0; top: 36px; width: min(360px, 90vw); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 20; max-height: 70vh; overflow: auto; }
.notif-panel ul { list-style: none; margin: 0; padding: 0; }
.notif-panel li a { display: block; padding: 10px 12px; text-decoration: none; color: var(--text); border-bottom: 1px solid var(--border); font-size: 0.92rem; }
.notif-panel li.unread a { background: var(--info-soft); }
.notif-panel .notif-foot { display: flex; justify-content: space-between; padding: 8px 12px; font-size: 0.85rem; }
.notif-list li.unread { font-weight: 600; }

/* Building blocks */
.card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space);
  box-shadow: var(--shadow);
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; color: var(--bow); }
.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.section { margin: 28px 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }
li.row, p.row, div.row, form.row { display: flex; }
.grid { display: grid; gap: var(--space); grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.split { display: grid; gap: 20px; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
@media (max-width: 960px) { .split { grid-template-columns: 1fr; } }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-sub { color: var(--text-muted); margin: 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hero { padding: 12px 0 28px; }
.hero-kitty {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
}
.hero-stickers {
  display: grid;
  grid-template-columns: repeat(3, 4.25rem);
  grid-template-rows: repeat(2, 4.25rem);
  gap: 10px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 2px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  place-items: center;
}
.hero-stickers .emote {
  width: 3.4rem;
  height: 3.4rem;
}
.hero-stickers .emote:nth-child(1) { transform: rotate(-8deg); }
.hero-stickers .emote:nth-child(2) { transform: rotate(4deg) scale(1.08); }
.hero-stickers .emote:nth-child(3) { transform: rotate(10deg); }
.hero-stickers .emote:nth-child(4) { transform: rotate(-4deg); }
.hero-stickers .emote:nth-child(5) {
  grid-column: 2;
  transform: rotate(6deg) scale(1.05);
}
@media (max-width: 700px) {
  .hero-kitty { grid-template-columns: 1fr; gap: 14px; }
  .hero-stickers {
    justify-self: stretch;
    width: 100%;
    box-sizing: border-box;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: auto;
    gap: 6px;
    padding: 10px;
    border-radius: 18px;
  }
  .hero-stickers .emote {
    width: 2.35rem;
    height: 2.35rem;
  }
  .hero-stickers .emote:nth-child(5) {
    grid-column: auto;
  }
  .hero h1 { font-size: clamp(1.85rem, 9vw, 2.4rem); }
}
.hero h1 {
  font-size: clamp(2.2rem, 5.5vw, 3.25rem);
  letter-spacing: -0.01em;
  color: var(--bow);
}
.kicker {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.tagline { font-size: 1.2rem; color: var(--text-muted); max-width: 36rem; }
.disclaimer {
  margin: 0.65rem 0 0;
  max-width: 34rem;
  font-size: 0.98rem;
  line-height: 1.45;
  color: var(--accent, #ff6b9d);
  font-style: italic;
}
.muted { color: var(--text-muted); }
.small { font-size: 0.88rem; }
.strong { font-weight: 700; }
.empty { color: var(--text-muted); font-style: italic; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.prose p:last-child { margin-bottom: 0; }
.prose h2 { margin-top: 1.4em; color: var(--bow); }
.prose ol, .prose ul { padding-left: 1.25rem; }
.prose li { margin: 0.35em 0; }
.prose code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--accent-soft);
  color: var(--bow);
  padding: 1px 6px;
  border-radius: 6px;
}
.rules .row { margin-top: 1.5rem; }

/* Yen ↔ USD converter */
.fx-card { margin-bottom: var(--space); }
.fx-card > h2 { display: flex; align-items: center; gap: 6px; }
.fx-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
}
.fx-field {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  margin: 0;
}
.fx-prefix { color: var(--bow); min-width: 1rem; }
.fx-field input { flex: 1; min-width: 0; }
.fx-swap {
  font-weight: 800;
  color: var(--accent);
  font-size: 1.1rem;
}
@media (max-width: 520px) {
  .fx-grid { grid-template-columns: 1fr; }
  .fx-swap { justify-self: center; }
}

/* Buttons */
.btn {
  display: inline-block;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover { background: var(--surface-alt); border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--bow); border-color: var(--bow); filter: none; }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-small { padding: 5px 12px; font-size: 0.85rem; }
.btn-link { background: none; border: none; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }
.btn-link.danger { color: var(--danger); }
.inline-form { display: inline; margin: 0; }
.file-btn { position: relative; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 0.95rem; }
.form label.check { flex-direction: row; align-items: flex-start; gap: 8px; font-weight: 400; }
.form fieldset { border: 1px solid var(--border); border-radius: var(--radius-small); padding: 10px; }
input, select, textarea {
  font: inherit;
  font-weight: 400;
  padding: 8px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  max-width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="checkbox"], input[type="radio"] { width: auto; }
input[type="color"] { padding: 2px; height: 40px; width: 80px; }
.hint { font-weight: 400; color: var(--text-muted); font-size: 0.85rem; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.money-input { display: flex; align-items: center; gap: 6px; }
.money-input::before { content: "¥"; color: var(--text-muted); font-weight: 700; }
.money-input input { flex: 1; }

/* Flash messages */
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; border: 2px solid transparent; }
.flash ul { margin: 0; padding-left: 18px; }
.flash-success { background: var(--success-soft); color: var(--success); border-color: var(--success); }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.flash-info { background: var(--info-soft); color: var(--info); border-color: var(--info); }

/* Tags, badges, places */
.tag, .badge { display: inline-block; font-size: 0.75rem; padding: 2px 10px; border-radius: var(--radius-pill); background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); white-space: nowrap; font-weight: 700; }
.tag-open { background: var(--success-soft); color: var(--success); border-color: transparent; }
.tag-upcoming, .tag-closed { background: var(--info-soft); color: var(--info); border-color: transparent; }
.tag-revealed { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.tag-draft { border-style: dashed; }
.tag-over { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tag-exact, .tag-bonus { background: var(--bonus-soft); color: var(--bonus); border-color: transparent; }
.badge-host { background: var(--accent); color: var(--accent-contrast); border-color: transparent; }
.badge-user { background: var(--bonus-soft); color: var(--bonus); border-color: transparent; }
.place { font-weight: 700; }
.place-1 { color: var(--place-1); }
.place-2 { color: var(--place-2); }
.place-3 { color: var(--place-3); }
.points { font-weight: 600; font-size: 0.9rem; color: var(--text-muted); }
.money { font-variant-numeric: tabular-nums; font-weight: 600; }
.countdown { white-space: nowrap; }

/* Players and teams */
.user { display: inline-flex; align-items: center; gap: 5px; text-decoration: none; color: var(--text); font-weight: 600; }
.user.has-team .user-display { color: var(--team-color); }
.user-emblem, .team-emblem { color: var(--team-color, var(--text)); }
.team-link { text-decoration: none; color: var(--team-color, var(--text)); font-weight: 600; }
.team-card { border-top: 4px solid var(--team-color); }
.team-card h3 a { color: var(--team-color); text-decoration: none; }
.emblem-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.emblem-option { flex-direction: row !important; align-items: center; gap: 4px !important; border: 1px solid var(--border); border-radius: var(--radius-small); padding: 4px 8px; cursor: pointer; font-size: 1.2rem; }
.emblem-option.taken { opacity: 0.35; cursor: not-allowed; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.me td { background: var(--info-soft); }
dl.stats { display: flex; flex-wrap: wrap; gap: 16px; margin: 12px 0; }
dl.stats dt { font-size: 0.8rem; color: var(--text-muted); }
dl.stats dd { margin: 0; font-size: 1.3rem; font-weight: 700; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0 0 12px; }
dl.kv dt { color: var(--text-muted); }
dl.kv dd { margin: 0; }

/* Photos and items */
.photo { width: 100%; border-radius: var(--radius); display: block; background: var(--surface-alt); }
.item-thumb { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-small); display: block; background: var(--surface-alt); }
.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius-small); }
.gallery { display: grid; gap: 10px; }
.small-gallery { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
.remove-photo { font-weight: 400 !important; font-size: 0.85rem; }
.item-card { display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: var(--text); }
.item-card:hover { border-color: var(--accent); }
.item-card h3 { margin: 0; }
.thumb-card { display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: var(--text); }
.reveal { text-align: center; padding: 12px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin: 12px 0; }
.reveal-label { margin: 0; color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }
.reveal-price { font-size: 2rem; font-weight: 800; margin: 0; }

/* Captions */
.caption-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.caption { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-small); background: var(--surface); }
.caption.ranked { border-color: var(--place-1); }
.caption.me { background: var(--info-soft); }
.caption-challenge { margin-bottom: 20px; }

/* Chat */
.chat-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 960px) { .chat-layout { grid-template-columns: 1fr; } }
.chat-room { display: flex; flex-direction: column; gap: 12px; }
.chat-messages { list-style: none; margin: 0; padding: 0; height: 60vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { padding: 6px 2px; border-bottom: 1px solid var(--border); }
.chat-meta { display: flex; gap: 8px; align-items: baseline; font-size: 0.9rem; }
.chat-meta time { color: var(--text-muted); font-size: 0.8rem; }
.chat-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-img { max-height: 220px; width: auto; border-radius: var(--radius-small); margin-top: 6px; display: block; }
.mention { background: var(--accent-soft); border-radius: 3px; padding: 0 2px; font-weight: 600; }
.chat-form { display: flex; flex-direction: column; gap: 8px; }
.chat-form textarea { width: 100%; resize: vertical; }
.chat-form .row { justify-content: space-between; }
.mention-box { position: relative; }
.mention-list { position: absolute; bottom: 100%; left: 0; list-style: none; margin: 0 0 4px; padding: 4px 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-small); box-shadow: 0 6px 18px rgba(0,0,0,.1); min-width: 220px; max-height: 220px; overflow: auto; z-index: 5; }
.mention-list button { display: block; width: 100%; text-align: left; background: none; border: none; padding: 6px 10px; font: inherit; cursor: pointer; }
.mention-list button:hover, .mention-list button.active { background: var(--surface-alt); }
.announcements { max-height: 70vh; overflow-y: auto; }
.announcement { border-bottom: 1px solid var(--border); padding: 8px 0; }
.announcement summary { cursor: pointer; display: flex; flex-direction: column; }
.announcement summary time { color: var(--text-muted); font-size: 0.8rem; }
.announcement .prose { padding-top: 8px; }
.announcement img { max-width: 100%; height: auto; }
.ann-title { font-weight: 600; }
.award-row { padding-bottom: 12px; border-bottom: 1px solid var(--border); }
