﻿:root {
  color-scheme: dark;
  --felt: #123d31;
  --felt-light: #1a5745;
  --ink: #f6f0df;
  --gold: #f0c76e;
  --card-w: clamp(42px, 11.4vw, 112px);
  --card-h: calc(var(--card-w) * 1.42);
  font-family: Inter, "Noto Sans JP", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -20%, rgba(255,255,255,.13), transparent 48%),
    linear-gradient(145deg, var(--felt-light), var(--felt));
}

button { font: inherit; }
.app { width: min(100%, 1040px); margin: auto; padding: max(14px, env(safe-area-inset-top)) 14px 28px; }
.topbar { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.eyebrow { margin: 0 0 3px; color: var(--gold); font-size: 10px; font-weight: 900; letter-spacing: .18em; }
h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(24px, 4vw, 40px); font-weight: 500; }
.status { display: flex; align-items: center; flex-wrap: wrap; justify-content: end; gap: 10px 16px; font-size: 13px; }
.status strong { color: var(--gold); font-variant-numeric: tabular-nums; }
button { border: 1px solid rgba(255,255,255,.25); border-radius: 999px; padding: 8px 14px; color: var(--ink); background: rgba(0,0,0,.18); cursor: pointer; }
button:hover { background: rgba(255,255,255,.12); }
button:disabled { opacity: .38; cursor: default; }
.title-screen {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(20px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
  background:
    linear-gradient(90deg, rgba(0,0,0,.22), rgba(0,0,0,.02) 28%, rgba(0,0,0,.02) 72%, rgba(0,0,0,.24)),
    radial-gradient(circle at 50% 52%, rgba(0,0,0,.42), rgba(0,0,0,.16) 34%, rgba(0,0,0,.02) 58%),
    url("assets/branding/title-background.png") center / cover no-repeat,
    linear-gradient(145deg, #0a211b, #123d31 58%, #071b16);
  overflow: hidden;
}
.title-screen[hidden] { display: none; }
.title-card {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  padding: 26px 24px 22px;
  text-align: center;
  border: 1px solid rgba(240,199,110,.34);
  border-radius: 24px;
  background: rgba(7,27,22,.5);
  box-shadow: 0 22px 70px rgba(0,0,0,.34);
  backdrop-filter: blur(1px);
}
.title-card::before {
  content: none;
}
.title-card h1 {
  position: relative;
  margin: 0;
  color: #ffe4a4;
  font-size: clamp(48px, 8vw, 90px);
  line-height: .95;
  text-shadow: 0 5px 0 rgba(0,0,0,.18), 0 14px 34px rgba(0,0,0,.74);
}
.title-copy {
  position: relative;
  margin: 14px auto 18px;
  color: rgba(255,255,255,.9);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.7;
  text-shadow: 0 3px 12px rgba(0,0,0,.78);
}
.title-language {
  position: relative;
  display: inline-grid;
  grid-template-columns: repeat(3, auto);
  gap: 4px;
  margin: 0 auto 24px;
  padding: 4px;
  border: 1px solid rgba(240,199,110,.3);
  border-radius: 999px;
  background: rgba(0,0,0,.42);
  box-shadow: 0 12px 28px rgba(0,0,0,.3);
}
.title-language button {
  min-height: 32px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  color: rgba(255,255,255,.78);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
}
.title-language button[aria-pressed="true"] {
  color: #123d31;
  background: var(--gold);
}
.title-hero {
  display: none;
}
.title-hero img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 24px;
  object-fit: cover;
}
.title-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  width: min(340px, 86vw);
  margin: 0 auto;
}
.title-actions button {
  min-height: 48px;
  padding: 10px 16px;
  border: 1px solid rgba(240,199,110,.45);
  border-radius: 999px;
  color: rgba(255,244,212,.96);
  background: rgba(0,0,0,.34);
  font-size: 18px;
  font-family: "Noto Sans JP", system-ui, sans-serif;
  font-weight: 900;
  letter-spacing: 0;
  text-shadow: 0 3px 10px rgba(0,0,0,.86);
  box-shadow: 0 10px 24px rgba(0,0,0,.22);
}
.title-actions button:hover {
  color: #ffe39a;
  background: rgba(240,199,110,.12);
  transform: translateY(-1px);
}
.title-actions .primary-title-action {
  color: #123d31;
  border-color: transparent;
  background: var(--gold);
  font-size: 20px;
  text-transform: none;
}
.title-status {
  min-height: 18px;
  margin: 18px 0 0;
  color: rgba(255,255,255,.78);
  font-size: 12px;
  font-weight: 800;
  text-shadow: 0 2px 8px rgba(0,0,0,.78);
}
.app[hidden] { display: none; }
.rank-chip { color: var(--gold); border-color: rgba(240,199,110,.42); font-weight: 800; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: -6px 0 18px; }
.toolbar button { padding: 7px 12px; font-size: 12px; }
.game-menu-panel { width: min(420px, 100%); text-align: center; }
.game-menu-actions { display: grid; gap: 10px; margin-top: 18px; }
.game-menu-actions button { min-height: 44px; border-color: rgba(240,199,110,.34); background: rgba(255,255,255,.06); font-weight: 800; }
.game-menu-actions button:first-child { color: #123d31; border-color: transparent; background: var(--gold); }
.first-tip {
  position: relative;
  margin: -4px 0 18px;
  padding: 12px 42px 12px 14px;
  border: 1px solid rgba(240,199,110,.34);
  border-radius: 14px;
  background: rgba(0,0,0,.18);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.first-tip[hidden] { display: none; }
.first-tip strong { display: block; color: var(--gold); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.first-tip p { margin: 5px 0 0; color: rgba(255,255,255,.76); font-size: 12px; line-height: 1.6; }
.first-tip button { position: absolute; top: 9px; right: 9px; width: 26px; height: 26px; padding: 0; }
.game { min-height: 600px; }
.upper-row, .pile-group, .foundations { display: flex; gap: clamp(5px, 1.2vw, 12px); }
.upper-row { justify-content: space-between; margin-bottom: 24px; }
.pile, .tableau-pile { position: relative; width: var(--card-w); min-width: var(--card-w); }
#waste { width: calc(var(--card-w) + min(72px, var(--card-w))); }
.slot { height: var(--card-h); border: 1px dashed rgba(255,255,255,.24); border-radius: calc(var(--card-w) * .09); }
.slot::before { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255,255,255,.18); font-family: Georgia, serif; font-size: calc(var(--card-w) * .34); }
#stock:empty::before { content: "\21BA"; }
.foundation[data-suit="hearts"]::before { content: "\2665"; }
.foundation[data-suit="diamonds"]::before { content: "\2666"; }
.foundation[data-suit="clubs"]::before { content: "\2663"; }
.foundation[data-suit="spades"]::before { content: "\2660"; }
.tableau { display: flex; align-items: flex-start; gap: clamp(5px, 1.2vw, 12px); }
.tableau-pile { min-height: var(--card-h); border-radius: calc(var(--card-w) * .09); outline: 1px dashed rgba(255,255,255,.12); }
.card {
  position: absolute;
  left: 0;
  width: var(--card-w);
  height: var(--card-h);
  border: 1px solid rgba(0,0,0,.35);
  border-radius: calc(var(--card-w) * .09);
  color: #171715;
  background: linear-gradient(145deg, #fffef9, #e8e3d8);
  box-shadow: 0 3px 8px rgba(0,0,0,.28);
  cursor: pointer;
  user-select: none;
  transition: transform .12s ease, box-shadow .12s ease;
}
.card:not(.face-down) { touch-action: none; }
.dragging, .dragging * { cursor: grabbing !important; }
.drag-ghost {
  position: fixed !important;
  z-index: 2000 !important;
  top: 0;
  left: 0;
  pointer-events: none;
  opacity: .9;
  transform: translate(-50%, -22%) rotate(2deg) scale(1.04);
  box-shadow: 0 14px 28px rgba(0,0,0,.48);
}
.drag-count {
  position: absolute;
  right: -8px;
  bottom: -8px;
  padding: 4px 7px;
  border-radius: 999px;
  color: #123d31;
  background: var(--gold);
  font-size: 11px;
  font-weight: 900;
}
.foundation.drop-target, .tableau-pile.drop-target {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
  background: rgba(240,199,110,.12);
}
.card.hint-source { animation: hint-pulse .75s ease-in-out 3; z-index: 300 !important; }
.hint-target { animation: target-pulse .75s ease-in-out 3; }
@keyframes hint-pulse { 50% { transform: translateY(-8px); box-shadow: 0 0 0 4px #fff2a8, 0 12px 22px rgba(0,0,0,.45); } }
@keyframes target-pulse { 50% { outline: 4px solid var(--gold); outline-offset: 4px; background: rgba(240,199,110,.18); } }
.card.red { color: #b32635; }
.card-content, .card-art, .corner, .big-suit, .pip-layout, .pip { pointer-events: none; }
.card-art { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: inherit; object-fit: cover; object-position: center 24%; }
.character-card::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; background: linear-gradient(135deg, rgba(255,255,255,.72), transparent 34%, transparent 72%, rgba(0,0,0,.24)); }
.character-card .corner { z-index: 4; min-width: 27%; padding: 5% 7%; border-radius: 6px; background: rgba(255,255,255,.9); box-shadow: 0 2px 5px rgba(0,0,0,.18); }
.character-card .big-suit { z-index: 3; place-items: end; padding: 8%; font-size: calc(var(--card-w) * .28); filter: drop-shadow(0 1px 1px #fff) drop-shadow(0 0 3px #fff); }
.card.face-down {
  background:
    linear-gradient(45deg, transparent 43%, rgba(255,255,255,.18) 44% 56%, transparent 57%) 0 0/12px 12px,
    linear-gradient(135deg, #223966, #4069a5);
  border: 3px solid #e7ddc8;
}
.card.face-down .card-content { display: none; }
.card.selected { transform: translateY(-6px); box-shadow: 0 0 0 3px var(--gold), 0 8px 15px rgba(0,0,0,.42); z-index: 100 !important; }
.card.waste-preview { pointer-events: none; filter: brightness(.92); }
.corner { position: absolute; top: 5%; left: 7%; text-align: center; font-family: Georgia, serif; font-size: calc(var(--card-w) * .19); font-weight: 700; line-height: .78; }
.corner .suit { display: block; font-size: .78em; margin-top: 3px; }
.big-suit { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--card-w) * .48); opacity: .92; }
.pip-layout { position: absolute; inset: 19% 14% 13%; }
.pip { position: absolute; left: var(--pip-x); top: var(--pip-y); font-family: Georgia, serif; font-size: calc(var(--card-w) * .195); line-height: 1; transform: translate(-50%, -50%); }
.pip.inverted { transform: translate(-50%, -50%) rotate(180deg); }
.tableau-pile .card { top: var(--top, 0px); }
.message { margin: 22px 0 0; text-align: center; color: rgba(255,255,255,.75); font-size: 13px; }
.win-dialog { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 20px; background: rgba(4,18,14,.76); backdrop-filter: blur(8px); }
.win-dialog[hidden] { display: none; }
.win-card { width: min(440px, 100%); max-height: calc(100vh - 40px); padding: 22px; overflow: auto; text-align: center; border: 1px solid rgba(240,199,110,.45); border-radius: 24px; background: #123d31; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.win-card h2 { font-family: Georgia, serif; font-size: 30px; font-weight: 500; }
.win-character { display: block; width: min(260px, 72vw); max-height: 56vh; aspect-ratio: 9 / 16; margin: 10px auto 6px; border: 2px solid rgba(240,199,110,.7); border-radius: 14px; background: #071b16; object-fit: contain; object-position: center; box-shadow: 0 12px 24px rgba(0,0,0,.35); }
.win-character.is-loading { opacity: 0; }
.win-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.win-card button { color: #123d31; background: var(--gold); font-weight: 800; }
.win-card .secondary-win-action { color: var(--ink); background: rgba(255,255,255,.08); }
.modal { position: fixed; inset: 0; z-index: 900; display: grid; place-items: start center; padding: 20px; overflow: auto; background: rgba(4,18,14,.74); backdrop-filter: blur(8px); touch-action: pan-y; }
.modal[hidden] { display: none; }
#unlock-confirm-dialog { z-index: 1200; }
#discovery-dialog { z-index: 1300; }
.preview-open { overflow: hidden; }
.image-preview { position: fixed; inset: 0; z-index: 3000; display: grid; width: 100%; height: 100%; padding: 18px; place-items: center; }
.image-preview[hidden] { display: none; }
.preview-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 0; background: rgba(3,10,8,.94); cursor: zoom-out; }
.preview-shell { position: relative; display: grid; max-width: 96vw; max-height: 96vh; place-items: center; touch-action: pan-y; }
.preview-shell img { display: block; max-width: 92vw; max-height: 88vh; border: 1px solid rgba(240,199,110,.5); border-radius: 12px; object-fit: contain; box-shadow: 0 30px 80px rgba(0,0,0,.65); }
.preview-caption { position: absolute; top: 12px; left: 12px; padding: 7px 11px; border-radius: 999px; color: #171715; background: rgba(255,255,255,.9); font-family: Georgia, serif; font-size: 18px; font-weight: 800; }
.preview-help { margin-top: 10px; color: rgba(255,255,255,.68); font-size: 12px; letter-spacing: .05em; }
.preview-nav { position: fixed; top: 50%; z-index: 2; width: 52px; height: 68px; padding: 0; border-color: rgba(240,199,110,.55); border-radius: 14px; color: #fff; background: rgba(7,27,22,.78); font-size: 34px; transform: translateY(-50%); }
.preview-previous { left: max(12px, env(safe-area-inset-left)); }
.preview-next { right: max(12px, env(safe-area-inset-right)); }
.preview-close { position: fixed; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); z-index: 3; width: 42px; height: 42px; padding: 0; border-radius: 50%; color: #fff; background: rgba(7,27,22,.82); font-size: 28px; }
.preview-nav[hidden] { display: none; }
.panel { position: relative; width: min(430px, 100%); padding: 30px; border: 1px solid rgba(240,199,110,.4); border-radius: 24px; background: #123d31; box-shadow: 0 28px 80px rgba(0,0,0,.55); }
.panel h2 { margin: 6px 0 22px; font-family: Georgia, serif; font-size: 28px; font-weight: 500; }
.confirm-panel { text-align: center; }
.confirm-copy { margin: -8px 0 22px; color: rgba(255,255,255,.72); font-size: 13px; line-height: 1.7; }
.confirm-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.confirm-actions button { min-width: 130px; color: #123d31; background: var(--gold); font-weight: 800; }
.confirm-actions .secondary-action { color: var(--ink); background: rgba(255,255,255,.08); }
.discovery-panel { width: min(420px, 100%); text-align: center; }
.discovery-image {
  display: block;
  width: min(220px, 62vw);
  aspect-ratio: 5 / 7;
  margin: -8px auto 18px;
  border: 2px solid rgba(240,199,110,.72);
  border-radius: 16px;
  background: #071b16;
  object-fit: cover;
  object-position: center 24%;
  box-shadow: 0 18px 38px rgba(0,0,0,.38);
}
.discovery-panel .confirm-copy { white-space: pre-line; }
.howto-panel { width: min(560px, 100%); }
.howto-video { display: block; width: 100%; max-height: min(56vh, 420px); margin: 0 0 16px; border: 2px solid rgba(240,199,110,.58); border-radius: 14px; background: #071b16; object-fit: contain; box-shadow: 0 12px 24px rgba(0,0,0,.28); }
.howto-list { display: grid; gap: 10px; margin: 0; padding-left: 1.25em; color: rgba(255,255,255,.78); font-size: 13px; line-height: 1.7; }
.close-modal { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; padding: 0; font-size: 20px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 0; border-top: 1px solid rgba(255,255,255,.1); }
.setting-row select { padding: 7px 10px; border: 1px solid rgba(255,255,255,.22); border-radius: 9px; color: var(--ink); background: #174b3c; }
.setting-row input { width: 20px; height: 20px; accent-color: var(--gold); }
.save-code-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.1); }
.save-code-actions button { min-height: 42px; border-color: rgba(240,199,110,.36); font-weight: 800; white-space: normal; }
.character-panel { width: min(560px, 100%); height: min(760px, calc(100vh - 40px)); height: min(760px, calc(100dvh - 40px)); overflow-y: scroll; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.character-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.character-choice { position: relative; display: grid; grid-template-columns: 78px 1fr; gap: 12px; align-items: center; padding: 10px; border-radius: 16px; text-align: left; background: rgba(255,255,255,.06); touch-action: pan-y; }
.character-choice img { width: 78px; height: 108px; border-radius: 11px; object-fit: cover; object-position: center 22%; }
.character-choice span { display: grid; gap: 5px; }
.character-choice strong { color: var(--gold); font-family: Georgia, serif; font-size: 22px; }
.character-choice small { color: rgba(255,255,255,.62); font-size: 11px; line-height: 1.45; }
.character-choice em { position: absolute; right: 10px; bottom: 10px; padding: 3px 7px; border-radius: 999px; color: rgba(255,255,255,.65); background: rgba(0,0,0,.2); font-size: 10px; font-style: normal; }
.character-choice.active { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(240,199,110,.28); background: rgba(240,199,110,.1); }
.character-choice.active em { color: #123d31; background: var(--gold); font-weight: 800; }
.character-choice.locked { opacity: .55; filter: grayscale(.8); }
.character-choice.locked img { filter: brightness(.55) grayscale(.8); }
.character-choice.locked em { color: #123d31; background: rgba(240,199,110,.85); font-weight: 900; }
.character-choice.can-buy { opacity: .72; filter: grayscale(.8); border-color: rgba(240,199,110,.75); background: rgba(240,199,110,.12); }
.character-choice.can-buy img { filter: brightness(.62) grayscale(.8); }
.character-choice.can-buy em { color: #123d31; background: var(--gold); font-weight: 900; }
.character-choice.secret-undiscovered { opacity: 1; filter: none; border-color: rgba(255,255,255,.2); }
.character-choice.secret-undiscovered img { filter: none; object-position: center; }
.character-choice.secret-undiscovered strong { color: rgba(255,255,255,.82); }
.outfit-section { margin-top: 18px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.12); }
.outfit-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.outfit-heading h3 { margin: 0; color: var(--gold); font-family: Georgia, serif; font-size: 24px; font-weight: 500; }
.outfit-heading p { margin: 0; color: rgba(255,255,255,.62); font-size: 11px; text-align: right; }
.outfit-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.outfit-choice { position: relative; display: grid; gap: 7px; padding: 9px; border-radius: 14px; text-align: left; background: rgba(255,255,255,.06); white-space: normal; touch-action: pan-y; }
.outfit-choice img { width: 100%; aspect-ratio: 9 / 12; border-radius: 10px; object-fit: cover; object-position: center 20%; background: rgba(0,0,0,.2); }
.outfit-choice strong { color: var(--gold); font-size: 13px; }
.outfit-choice small { color: rgba(255,255,255,.62); font-size: 10px; line-height: 1.35; }
.outfit-choice em { position: absolute; right: 8px; top: 8px; padding: 3px 7px; border-radius: 999px; color: rgba(255,255,255,.68); background: rgba(0,0,0,.35); font-size: 10px; font-style: normal; }
.outfit-choice.active { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(240,199,110,.25); background: rgba(240,199,110,.1); }
.outfit-choice.active em, .outfit-choice.can-buy em { color: #123d31; background: var(--gold); font-weight: 900; }
.outfit-choice.locked { opacity: .55; filter: grayscale(.75); }
.outfit-choice.locked img { filter: brightness(.58) grayscale(.8); }
.outfit-choice.can-buy { opacity: 1; filter: none; border-color: rgba(240,199,110,.72); background: rgba(240,199,110,.12); }
.outfit-choice.preview-only { opacity: 1; filter: none; border-color: rgba(255,255,255,.16); }
.outfit-choice.preview-only img { filter: brightness(.82) saturate(.9); }
.outfit-choice.preview-only em { color: rgba(255,255,255,.72); background: rgba(0,0,0,.34); }
.outfit-choice.secret-undiscovered { opacity: 1; filter: none; border-color: rgba(255,255,255,.2); cursor: pointer; }
.outfit-choice.secret-undiscovered img { filter: none; object-position: center; }
.outfit-choice.secret-undiscovered strong { color: rgba(255,255,255,.82); }
.rank-display { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.rank-display strong { color: var(--gold); font-family: Georgia, serif; font-size: 30px; }
.rank-display span { color: rgba(255,255,255,.68); }
.xp-track { overflow: hidden; height: 8px; border-radius: 99px; background: rgba(255,255,255,.12); }
.xp-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #d49e3d, #ffe39a); transition: width .3s ease; }
.next-rank { min-height: 18px; color: rgba(255,255,255,.6); font-size: 12px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 22px 0 0; }
.stats-grid div { padding: 13px 8px; text-align: center; border-radius: 12px; background: rgba(255,255,255,.07); }
.stats-grid dt { color: rgba(255,255,255,.58); font-size: 11px; }
.stats-grid dd { margin: 5px 0 0; color: var(--gold); font-size: 18px; font-weight: 800; }
.title-record { margin-top: 22px; }
.title-record-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.title-record-heading h3 { margin: 0; color: var(--gold); font-family: Georgia, serif; font-size: 24px; font-weight: 500; }
.title-record-heading span { color: rgba(255,255,255,.66); font-size: 12px; font-weight: 800; }
.titles-list { display: grid; gap: 8px; }
.title-badge { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; padding: 11px 12px; border: 1px solid rgba(255,255,255,.1); border-radius: 12px; background: rgba(255,255,255,.06); }
.title-badge strong { color: var(--gold); font-size: 14px; }
.title-badge small { grid-column: 1 / -1; color: rgba(255,255,255,.62); font-size: 11px; line-height: 1.45; }
.title-badge em { align-self: start; padding: 3px 7px; border-radius: 999px; color: rgba(255,255,255,.62); background: rgba(0,0,0,.24); font-size: 10px; font-style: normal; font-weight: 800; }
.title-badge.earned { border-color: rgba(240,199,110,.48); background: rgba(240,199,110,.1); }
.title-badge.earned em { color: #123d31; background: var(--gold); }
.collection-panel { width: min(680px, 100%); max-height: calc(100vh - 40px); overflow: auto; }
.collection-help { margin: -10px 0 18px; color: rgba(255,255,255,.65); font-size: 12px; }
.collection-list { display: grid; gap: 16px; }
.collection-character-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.collection-character-card { position: relative; display: grid; gap: 9px; min-height: 0; padding: 9px; border-radius: 16px; text-align: left; background: rgba(255,255,255,.06); white-space: normal; }
.collection-character-card img { width: 100%; aspect-ratio: 5 / 7; border-radius: 12px; object-fit: cover; object-position: center 24%; background: #071b16; }
.collection-character-card strong { color: var(--gold); font-family: Georgia, serif; font-size: 19px; }
.collection-character-card small { color: rgba(255,255,255,.62); font-size: 11px; }
.collection-detail-heading { display: flex; align-items: center; gap: 12px; }
.collection-back { min-width: 42px; padding: 8px 12px; font-size: 20px; }
.collection-detail-heading h3 { margin: 0; }
.collection-character { padding: 14px; border-radius: 18px; background: rgba(255,255,255,.06); }
.collection-character h3 { margin: 0 0 10px; color: var(--gold); font-family: Georgia, serif; font-size: 24px; font-weight: 500; }
.collection-character h4 { margin: 14px 0 8px; color: rgba(255,255,255,.82); font-size: 12px; letter-spacing: .16em; text-transform: uppercase; }
.collection-locked-copy { margin: 0 0 10px; color: rgba(255,255,255,.58); font-size: 12px; line-height: 1.5; }
.collection-art-deck { display: grid; gap: 8px; margin-bottom: 12px; }
.collection-art-deck p { margin: 0; color: rgba(255,255,255,.68); font-size: 12px; font-weight: 700; }
.collection-art-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 8px; }
.collection-art-card { display: grid; gap: 5px; min-height: 0; padding: 6px; border-radius: 10px; text-align: center; background: rgba(255,255,255,.04); }
.collection-art-card img { width: 100%; aspect-ratio: 5 / 7; border-radius: 8px; object-fit: cover; object-position: center 24%; background: #071b16; }
.collection-art-card span { color: rgba(255,255,255,.74); font-size: 10px; font-weight: 800; }
.collection-tier-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.collection-item { display: grid; gap: 6px; min-height: 86px; padding: 12px; border-radius: 14px; text-align: left; white-space: normal; }
.collection-item strong { color: var(--gold); font-size: 15px; }
.collection-item small { color: rgba(255,255,255,.68); font-size: 11px; line-height: 1.45; }
.collection-item.locked { opacity: .48; filter: grayscale(.75); }
.collection-item.unlocked { border-color: rgba(240,199,110,.55); background: rgba(240,199,110,.1); }
.collection-video { display: block; width: min(260px, 72vw); max-height: 52vh; aspect-ratio: 9 / 16; margin: 18px auto 0; border: 2px solid rgba(240,199,110,.7); border-radius: 14px; background: #071b16; object-fit: contain; box-shadow: 0 12px 24px rgba(0,0,0,.35); }
.collection-video[hidden] { display: none; }

@media (max-width: 600px) {
  .preview-nav { width: 42px; height: 58px; font-size: 28px; }
  .preview-previous { left: 5px; }
  .preview-next { right: 5px; }
  .preview-shell img { max-width: calc(100vw - 58px); }
}

@media (min-width: 900px) and (orientation: landscape) {
  :root {
    --card-w: clamp(72px, min(7vw, 11vh), 118px);
  }

  .app {
    width: min(100%, 1180px);
    padding: max(16px, env(safe-area-inset-top)) clamp(18px, 3vw, 34px) 30px;
  }

  .topbar {
    margin-bottom: 14px;
  }

  .toolbar {
    justify-content: center;
    margin-bottom: 14px;
  }

  .game {
    min-height: min(690px, calc(100vh - 178px));
    min-height: min(690px, calc(100dvh - 178px));
  }

  .upper-row,
  .pile-group,
  .foundations,
  .tableau {
    gap: clamp(8px, .9vw, 14px);
  }

  .upper-row {
    margin-bottom: 20px;
  }
}

@media (min-width: 900px) and (orientation: landscape) and (max-height: 860px) {
  :root {
    --card-w: clamp(62px, min(6vw, 9.4vh), 92px);
  }

  .app {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: 18px;
  }

  .topbar {
    align-items: center;
    margin-bottom: 10px;
  }

  h1 {
    font-size: clamp(26px, 3vw, 36px);
  }

  .toolbar {
    margin-bottom: 10px;
  }

  .toolbar button {
    padding: 6px 10px;
  }

  .first-tip {
    margin-bottom: 12px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .first-tip p {
    line-height: 1.35;
  }

  .upper-row {
    margin-bottom: 14px;
  }

  .game {
    min-height: auto;
    padding-bottom: 10px;
  }

  .message {
    margin-top: 12px;
  }
}

@media (max-width: 700px) {
  .title-screen {
    align-items: center;
    padding: max(14px, env(safe-area-inset-top)) 8px max(14px, env(safe-area-inset-bottom));
    overflow: auto;
    background-position: center;
  }

  .title-card {
    width: min(420px, 100%);
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    padding: 18px 18px 16px;
    border-radius: 0;
    background: radial-gradient(circle at 50% 45%, rgba(0,0,0,.34), rgba(0,0,0,.02) 66%);
    overflow: auto;
  }

  .title-card h1 {
    font-size: clamp(42px, 12vw, 62px);
  }

  .title-copy {
    margin: 10px auto 16px;
    font-size: 13px;
    line-height: 1.6;
  }

  .title-hero {
    width: min(190px, 50vw);
    margin-bottom: 14px;
    border-radius: 24px;
  }

  .title-hero img {
    border-radius: 19px;
  }

  .title-actions {
    gap: 8px;
  }

  .title-actions button {
    min-height: 44px;
    padding: 9px 12px;
    font-size: 16px;
  }

  .title-actions .primary-title-action {
    font-size: 18px;
  }

  .title-status {
    margin-top: 10px;
    font-size: 11px;
  }
}

@media (max-width: 600px) {
  .app { padding-inline: 6px; }
  .topbar { align-items: flex-start; padding-inline: 6px; }
  .status { gap: 6px 9px; font-size: 11px; }
  .status button { padding: 6px 10px; }
  .game { min-height: 510px; }
  .upper-row { margin-bottom: 18px; }
  .message { margin-top: 12px; }
  .toolbar { padding-inline: 6px; margin-bottom: 12px; gap: 5px; }
  .toolbar button { padding: 6px 9px; font-size: 10px; }
  .first-tip { margin-inline: 6px; margin-bottom: 12px; padding: 10px 36px 10px 12px; }
  .first-tip p { font-size: 11px; }
  .rank-chip { order: 5; }
  .panel { padding: 26px 20px; }
  .modal { align-items: start; padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)); }
  .character-panel { max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px); }
  .win-dialog { padding: 10px; align-items: start; overflow: auto; }
  .win-card { max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px); padding: 18px 14px 16px; border-radius: 20px; }
  .win-card h2 { margin: 10px 0 8px; font-size: 26px; }
  .win-card .eyebrow { margin-bottom: 6px; }
  .win-character { width: min(230px, 64vw); max-height: 42vh; margin-top: 6px; }
  #win-result { margin: 10px 0 12px; font-size: 13px; line-height: 1.55; }
  .win-actions button { min-width: 132px; padding: 9px 13px; }
  .collection-panel { max-height: calc(100vh - 22px); max-height: calc(100dvh - 22px); }
  .collection-video { width: min(230px, 64vw); max-height: 42vh; }
  .character-grid { grid-template-columns: 1fr; }
  .collection-tier-grid { grid-template-columns: 1fr; }
}

@media (orientation: landscape) and (max-height: 520px) {
  :root {
    --card-w: clamp(34px, 5.8vw, 52px);
  }

  body {
    overflow: auto;
    min-height: auto;
  }

  .app {
    width: 100%;
    padding: max(4px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  .topbar {
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
  }

  .topbar .eyebrow {
    display: none;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .status {
    gap: 5px 8px;
    font-size: 11px;
  }

  .status button,
  .toolbar button {
    padding: 4px 7px;
    font-size: 10px;
  }

  .toolbar {
    flex-wrap: nowrap;
    gap: 5px;
    margin: 0 0 8px;
    overflow-x: auto;
    padding-bottom: 3px;
  }

  .first-tip {
    display: none;
  }

  .game {
    min-height: auto;
    padding-bottom: 22px;
    touch-action: pan-x pan-y pinch-zoom;
  }

  .card,
  .card:not(.face-down) {
    touch-action: manipulation;
  }

  .upper-row,
  .pile-group,
  .foundations,
  .tableau {
    gap: clamp(4px, .75vw, 8px);
  }

  .upper-row {
    margin-bottom: 6px;
  }

  .message {
    margin-top: 4px;
    padding-bottom: 20px;
    font-size: 11px;
  }

  .tableau-pile {
    min-height: calc(var(--card-h) * 1.1);
  }

  .win-dialog {
    padding: 8px;
  }

  .win-card {
    width: min(760px, 100%);
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    padding: 12px;
    display: grid;
    grid-template-columns: minmax(150px, 34%) 1fr;
    grid-template-areas:
      "video eyebrow"
      "video title"
      "video result"
      "video actions";
    align-items: center;
    column-gap: 14px;
  }

  .win-card .eyebrow { grid-area: eyebrow; margin: 0; }
  .win-card h2 { grid-area: title; margin: 4px 0; font-size: 24px; }
  #win-result { grid-area: result; margin: 4px 0 8px; font-size: 12px; line-height: 1.45; }
  .win-character { grid-area: video; width: min(190px, 28vw); max-height: calc(100vh - 44px); max-height: calc(100dvh - 44px); margin: 0 auto; }
  .win-actions { grid-area: actions; }
  .win-actions button { padding: 8px 12px; font-size: 12px; }

  .collection-panel {
    width: min(780px, 100%);
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    padding: 18px;
  }

  .collection-video {
    width: min(190px, 28vw);
    max-height: calc(100vh - 72px);
    max-height: calc(100dvh - 72px);
  }
}
