:root {
  --felt: #123b2f;
  --felt-light: #1d5746;
  --ink: #13251f;
  --cream: #f8f3e6;
  --cream-2: #e8dec4;
  --gold: #efc765;
  --gold-dark: #9c7725;
  --red: #b3262f;
  --card-w: clamp(42px, 9.8vw, 94px);
  --card-h: calc(var(--card-w) * 1.42);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--cream);
  background: var(--felt);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background:
  radial-gradient(circle at 20% 0%, #2a6c56 0, transparent 34rem),
  repeating-linear-gradient(118deg, #ffffff05 0 1px, transparent 1px 5px),
  var(--felt); }
button, input { font: inherit; }
button { color: inherit; }

.loading-screen, .install-needed { min-height: 100vh; display: grid; place-items: center; text-align: center; padding: 24px; }
.loading-card { width: 68px; height: 96px; display: grid; place-items: center; margin: auto; background: var(--cream); color: #111; border-radius: 9px; font: 700 24px Georgia, serif; box-shadow: 0 16px 40px #0005; transform: rotate(-4deg); }
.install-needed > div { max-width: 480px; }

.site-shell { width: min(1180px, 100%); margin: 0 auto; padding: 18px clamp(10px, 2.8vw, 34px) 42px; }
.site-header { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid #ffffff22; padding-bottom: 14px; }
.brand { display: flex; align-items: baseline; gap: 11px; min-width: 0; }
.brand-mark { font: 800 clamp(18px, 2.2vw, 27px)/1 Georgia, serif; letter-spacing: .14em; color: var(--gold); }
.brand-sub { font: italic 500 clamp(13px, 1.7vw, 18px)/1 Georgia, serif; color: #e8dec4cc; white-space: nowrap; }
.user-menu { display: flex; align-items: center; gap: 10px; }
.user-name { max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.text-button { border: 0; padding: 8px 2px; background: transparent; color: #f8f3e6aa; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.text-button:hover { color: white; }

.eyebrow { margin: 0 0 9px; color: var(--gold); font-weight: 850; font-size: 12px; letter-spacing: .18em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; }

.auth-wrap { min-height: calc(100vh - 110px); display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(320px, .75fr); gap: clamp(28px, 7vw, 90px); align-items: center; padding: 50px clamp(0px, 4vw, 55px); }
.auth-intro h1 { max-width: 660px; margin-bottom: 22px; font-size: clamp(46px, 7vw, 86px); line-height: .96; letter-spacing: -.045em; font-weight: 500; }
.auth-intro p:last-child { max-width: 560px; color: #f8f3e6ba; font-size: clamp(17px, 2vw, 21px); line-height: 1.6; }
.auth-card { background: var(--cream); color: var(--ink); border: 1px solid #fff9; border-radius: 20px; padding: clamp(22px, 4vw, 34px); box-shadow: 0 30px 80px #071b155c; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: #ded5bf; border-radius: 999px; margin-bottom: 26px; }
.auth-tab { border: 0; border-radius: 999px; padding: 10px; background: transparent; color: #5d594f; cursor: pointer; font-weight: 750; }
.auth-tab.active { background: #fffdf6; color: var(--ink); box-shadow: 0 2px 8px #493d1b20; }
.field { display: block; margin: 14px 0; }
.field span { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 800; }
.field input { width: 100%; border: 1px solid #bcb29b; border-radius: 11px; padding: 12px 14px; background: #fffdf8; color: var(--ink); outline: none; }
.field input:focus { border-color: var(--gold-dark); box-shadow: 0 0 0 3px #efc76545; }
.primary-button { display: inline-flex; justify-content: center; align-items: center; min-height: 44px; border: 0; border-radius: 999px; padding: 11px 20px; background: var(--gold); color: #173126; text-decoration: none; font-weight: 900; cursor: pointer; box-shadow: 0 6px 18px #0002; }
.auth-card .primary-button { width: 100%; margin-top: 10px; background: var(--felt); color: white; }
.form-error { min-height: 22px; margin: 4px 0; color: var(--red); font-size: 14px; font-weight: 700; }

.player-panel { display: grid; grid-template-columns: minmax(210px, .8fr) minmax(260px, 1.7fr) auto; gap: 18px; align-items: center; margin: 18px 0; padding: 16px 18px; background: #071f1966; border: 1px solid #ffffff19; border-radius: 16px; }
.rank-name { margin: 0; font-size: clamp(22px, 3vw, 34px); line-height: 1; }
.progress-copy { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 7px; color: #f8f3e6ba; font-size: 13px; }
.progress-track { height: 8px; overflow: hidden; background: #04130f99; border-radius: 99px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #d9a936, var(--gold)); border-radius: inherit; }
.collection { display: flex; gap: 6px; flex-wrap: wrap; }
.collection-item { border: 1px solid #efc76566; border-radius: 99px; color: var(--gold); padding: 4px 9px; font-size: 12px; font-weight: 800; }
.collection-empty { color: #f8f3e680; font-size: 13px; }
.moves-counter { min-width: 84px; text-align: right; color: #f8f3e6a8; font-size: 13px; }
.moves-counter strong { display: block; color: white; font: 500 28px Georgia, serif; }

.level-picker { min-height: calc(100vh - 205px); display: grid; align-content: center; padding: 26px 0 60px; }
.level-heading { max-width: 670px; margin: 0 auto 30px; text-align: center; }
.level-heading h1 { margin-bottom: 12px; font-size: clamp(34px, 5vw, 60px); font-weight: 500; letter-spacing: -.03em; }
.level-heading p { color: #f8f3e6a9; line-height: 1.55; }
.level-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.level-card { min-height: 240px; display: flex; flex-direction: column; align-items: flex-start; text-align: left; border: 1px solid #ffffff25; border-radius: 18px; padding: 22px; background: linear-gradient(155deg, #ffffff12, #00000010); cursor: pointer; transition: transform .18s ease, background .18s ease, border-color .18s ease; }
.level-card:hover { transform: translateY(-4px); background: #ffffff17; border-color: #efc76580; }
.difficulty-number { color: #ffffff35; font: 500 46px/1 Georgia, serif; }
.level-card h2 { margin: 34px 0 8px; font-size: 29px; }
.level-card p { margin-bottom: 18px; color: #f8f3e69c; }
.reward { margin-top: auto; color: var(--gold); font-weight: 900; }

.game-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 14px; }
.game-title { min-width: 0; }
.game-title h2 { display: inline; font-size: 21px; }
.game-title span { margin-left: 8px; color: #f8f3e680; font-size: 12px; }
.toolbar-actions { display: flex; gap: 8px; }
.small-button { border: 1px solid #ffffff30; border-radius: 99px; padding: 8px 12px; background: #09261e88; cursor: pointer; font-size: 13px; font-weight: 800; }
.small-button:hover:not(:disabled) { border-color: var(--gold); }
.small-button:disabled { opacity: .35; cursor: not-allowed; }

.board { user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.top-row, .columns { display: grid; grid-template-columns: repeat(8, var(--card-w)); justify-content: space-between; gap: clamp(2px, .7vw, 9px); }
.top-row { align-items: center; margin-bottom: clamp(18px, 3vw, 34px); }
.top-divider { display: none; }
.slot, .playing-card { width: var(--card-w); height: var(--card-h); border-radius: clamp(5px, .8vw, 10px); }
.slot { position: relative; display: grid; place-items: center; border: 1px solid #ffffff3d; background: #041c1670; cursor: pointer; }
.slot::after { color: #ffffff25; font: 500 clamp(18px, 3vw, 34px)/1 Georgia, serif; }
.cell-slot:empty::after { content: "•"; }
.foundation-slot::after { content: attr(data-symbol); }
.foundation-slot.has-card::after { content: none; }
.playing-card { position: relative; flex: 0 0 auto; border: 1px solid #b8ae99; background:
  linear-gradient(145deg, #fffef8 0%, #f0eadc 100%); color: #171714; box-shadow: 0 3px 7px #0004; cursor: pointer; padding: 0; text-align: left; transition: transform .12s ease, box-shadow .12s ease; }
.playing-card.red { color: var(--red); }
.playing-card:hover { transform: translateY(-2px); box-shadow: 0 5px 12px #0005; }
.playing-card.selected { outline: 3px solid var(--gold); outline-offset: 1px; transform: translateY(-5px); }
.card-corner { position: absolute; top: 7%; left: 9%; display: flex; flex-direction: column; align-items: center; font: 800 clamp(10px, 1.9vw, 18px)/.9 Georgia, serif; }
.card-suit-big { position: absolute; inset: 0; display: grid; place-items: center; padding-top: 13%; font: 500 clamp(20px, 4.5vw, 43px)/1 Georgia, serif; opacity: .93; }
.columns { align-items: start; min-height: calc(var(--card-h) * 2.9); }
.column { min-width: 0; min-height: var(--card-h); display: flex; flex-direction: column; align-items: center; border-radius: 10px; }
.column.empty { border: 1px dashed #ffffff22; }
.column .playing-card + .playing-card { margin-top: calc(var(--card-w) * -.98); }

.toast { position: fixed; z-index: 20; left: 50%; bottom: 24px; max-width: min(90vw, 520px); transform: translate(-50%, 30px); opacity: 0; pointer-events: none; border-radius: 99px; background: #0a1a15; color: white; padding: 11px 18px; box-shadow: 0 10px 40px #0007; transition: .2s ease; text-align: center; font-weight: 750; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.modal-backdrop { position: fixed; z-index: 10; inset: 0; display: grid; place-items: center; padding: 20px; background: #06130fd9; backdrop-filter: blur(6px); }
.result-card { width: min(520px, 100%); border: 1px solid #efc76577; border-radius: 24px; padding: 34px; background: var(--cream); color: var(--ink); text-align: center; box-shadow: 0 30px 90px #0008; }
.result-card h2 { font-size: clamp(38px, 7vw, 64px); margin-bottom: 12px; font-weight: 500; }
.result-reward { color: var(--gold-dark); font: 700 27px Georgia, serif; }
.result-card .primary-button { margin-top: 12px; background: var(--felt); color: white; }

@media (max-width: 760px) {
  .site-shell { padding-top: 12px; }
  .brand-sub { display: none; }
  .auth-wrap { grid-template-columns: 1fr; align-content: center; gap: 20px; padding-top: 34px; }
  .auth-intro { text-align: center; }
  .auth-intro h1 { margin-inline: auto; font-size: clamp(42px, 13vw, 68px); }
  .auth-intro p:last-child { display: none; }
  .player-panel { grid-template-columns: 1fr auto; gap: 12px; padding: 12px; }
  .rank-progress { grid-column: 1 / -1; grid-row: 2; }
  .moves-counter { grid-column: 2; grid-row: 1; }
  .level-grid { grid-template-columns: 1fr; }
  .level-card { min-height: 150px; }
  .level-card h2 { margin-top: 20px; }
  .game-title span { display: none; }
  .small-button { padding: 7px 9px; }
  .card-corner { top: 6%; }
  .columns { min-height: calc(var(--card-h) * 3.6); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
