
:root {
  --cream:       #faf6ec;
  --cream-2:     #f2ebd8;
  --paper:       #ffffff;
  --ink:         #1c2530;
  --ink-soft:    #4a5566;
  --line:        #d9cfae;
  --line-soft:   #ebe3c9;
  --maroon:      #7E95B5;
  --maroon-2:    #5a7590;
  --gold:        #3d5a80;
  --gold-2:      #2d4460;
  --good:        #2f6b3b;
  --bad:         #9b2222;
  --neutral:     #6b6b6b;
  --red-suit:    #b02323;
  --black-suit:  #1c2530;
  --shadow:      0 2px 4px rgba(28,37,48,0.06), 0 8px 20px rgba(28,37,48,0.06);
  --radius:      12px;
  --radius-lg:   18px;
  --font-serif:  Georgia, "Iowan Old Style", "Cambria", serif;
  --font-sans:   -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono:   "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* -------- Header / Nav -------- */
.site-header {
  background: linear-gradient(180deg, #fffbef 0%, var(--cream) 100%);
  border-bottom: 1px solid var(--line);
  padding: 28px 24px 0;
}
.header-inner { max-width: 1120px; margin: 0 auto; }
.brand { display: flex; gap: 18px; align-items: flex-start; }
.brand-mark {
  font-family: var(--font-serif);
  background: var(--maroon);
  color: #fff8e6;
  font-size: 28px;
  font-weight: bold;
  padding: 8px 14px;
  border-radius: 10px;
  letter-spacing: 1px;
  box-shadow: var(--shadow);
}
.brand-text h1 {
  font-family: var(--font-serif);
  font-size: 28px;
  margin: 0 0 4px 0;
  color: var(--maroon-2);
  font-weight: 700;
}
.subtitle {
  margin: 0;
  color: var(--ink-soft);
  font-size: 15px;
}
.chick { font-size: 22px; }
.chick-sm { font-size: 15px; opacity: 0.9; }

.top-nav {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 2px solid var(--maroon);
}
.top-nav a {
  color: var(--maroon-2);
  text-decoration: none;
  padding: 6px 10px;
  font-size: 13px;
  font-family: var(--font-serif);
  border-radius: 6px;
  transition: background 0.15s;
}
.top-nav a:hover { background: var(--cream-2); color: var(--maroon); }

/* -------- Page & sections -------- */
.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}
.section {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 26px;
  box-shadow: var(--shadow);
}
.section h2 {
  font-family: var(--font-serif);
  color: var(--maroon-2);
  border-bottom: 2px solid var(--gold);
  padding-bottom: 8px;
  margin: 0 0 16px 0;
  font-size: 22px;
}
.section h3 {
  font-family: var(--font-serif);
  color: var(--maroon-2);
  margin: 18px 0 8px;
  font-size: 17px;
}
.numeral {
  color: var(--gold-2);
  font-weight: normal;
  margin-right: 8px;
  font-variant: small-caps;
}
.section p { margin: 10px 0; }
code {
  font-family: var(--font-mono);
  background: var(--cream-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

.callout {
  background: linear-gradient(90deg, #fdf6dd, #f6edc9);
  border-left: 4px solid var(--gold);
  padding: 12px 16px;
  border-radius: 8px;
  margin: 16px 0;
  color: var(--ink);
  font-size: 14.5px;
}

.fact-list { padding-left: 22px; }
.fact-list li { margin: 6px 0; }

.rank-strip {
  text-align: center;
  background: var(--cream-2);
  padding: 12px;
  border-radius: 8px;
  border: 1px dashed var(--gold);
  font-size: 15px;
}
.rank-strip code { background: transparent; letter-spacing: 2px; }
.rank-strip-cards {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
  background: var(--cream-2);
  padding: 14px 10px;
  border-radius: 8px;
  border: 1px dashed var(--gold);
}
.rank-card {
  width: 46px;
  height: 68px;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
  border-radius: 4px;
  background: #fff;
}

/* -------- Penalty grid -------- */
.penalty-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 16px 0;
}
.penalty-card {
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  position: relative;
}
.pc-head {
  font-family: var(--font-serif);
  font-size: 30px;
  color: var(--maroon);
  margin-bottom: 4px;
}
.pc-cards {
  height: 90px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 8px;
  padding: 0 4px;
}
.pc-card {
  width: 60px;
  height: 88px;
  object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.18));
  border-radius: 4px;
  background: #fff;
}
.pc-cards.stack .pc-card + .pc-card { margin-left: -40px; }
.pc-card.tiny {
  width: 34px;
  height: 50px;
  border-radius: 3px;
}
.pc-cards.tiny-stack .pc-card.tiny + .pc-card.tiny { margin-left: -27px; }
.pc-cards.fan .pc-card { transition: transform 0.25s; }
.pc-cards.fan .pc-card:nth-child(1) { transform: rotate(-10deg) translateY(2px); }
.pc-cards.fan .pc-card:nth-child(2) { transform: rotate(-3deg) translateY(-2px); margin-left: -30px; }
.pc-cards.fan .pc-card:nth-child(3) { transform: rotate(3deg) translateY(-2px);  margin-left: -30px; }
.pc-cards.fan .pc-card:nth-child(4) { transform: rotate(10deg) translateY(2px);  margin-left: -30px; }
.penalty-card:hover .pc-cards.fan .pc-card:nth-child(1) { transform: rotate(-14deg) translate(-6px, 0); }
.penalty-card:hover .pc-cards.fan .pc-card:nth-child(4) { transform: rotate(14deg)  translate(6px, 0);  }
.pc-val {
  font-family: var(--font-serif);
  font-size: 28px;
  color: var(--maroon-2);
  font-weight: 700;
}
.pc-val .each {
  display: block;
  font-size: 11px;
  color: var(--ink-soft);
  font-weight: normal;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.pc-desc { font-size: 13px; color: var(--ink-soft); margin-top: 8px; }
.penalty-king .pc-head { color: var(--red-suit); }
.penalty-diamond .pc-head { color: var(--red-suit); }

.max-loss {
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  background: var(--cream-2);
  padding: 10px;
  border-radius: 8px;
}

/* -------- Walkthrough / simulator -------- */
.walkthrough .sim-frame {
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin: 18px 0;
}
.sim-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.sim-controls button {
  background: var(--maroon);
  color: #fff8e6;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-serif);
  font-size: 14px;
  transition: background 0.15s, transform 0.1s;
}
.sim-controls button:hover { background: var(--maroon-2); }
.sim-controls button:active { transform: scale(0.97); }
.sim-controls button:disabled { background: #b8a898; cursor: not-allowed; }
.sim-controls .btn-primary {
  background: var(--gold);
  font-size: 15px;
  padding: 10px 22px;
}
.sim-controls .btn-primary:hover { background: var(--gold-2); }
.hidden-until-start { display: none; }
.sim-controls.started .hidden-until-start { display: inline-block; }
.sim-controls.started #btn-start { display: none; }
.sim-status {
  margin-left: auto;
  font-family: var(--font-serif);
  color: var(--maroon-2);
  font-size: 14px;
}

.table-wrap {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  grid-template-rows: auto auto auto;
  grid-template-areas:
    ".    north    .   "
    "west center   east"
    ".    south    .   ";
  gap: 10px;
  background: #eee1bd;
  padding: 20px;
  border-radius: var(--radius);
  min-height: 380px;
}
.seat-north  { grid-area: north; }
.seat-south  { grid-area: south; }
.seat-east   { grid-area: east; }
.seat-west   { grid-area: west; }
.trick-center{ grid-area: center; }

.seat {
  background: var(--paper);
  border-radius: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  position: relative;
}
.seat-label {
  font-family: var(--font-serif);
  font-size: 13px;
  color: var(--maroon-2);
  margin-bottom: 4px;
}
.pile-info {
  position: absolute;
  bottom: 4px;
  right: 8px;
  font-size: 11px;
  color: var(--ink-soft);
  font-family: var(--font-mono);
}
.hand {
  display: flex;
  gap: 0;
  min-height: 80px;
  padding-bottom: 14px;
  align-items: flex-end;
}
.hand .card + .card { margin-left: -26px; }
.hand-vert {
  min-height: 280px;
  flex-direction: column;
  align-items: center;
}
.hand-vert .card + .card { margin-left: 0; margin-top: -58px; }

/* Cards — real images, sized around a standard playing-card 500x726 aspect */
.card {
  display: inline-block;
  width: 52px;
  height: 76px;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  user-select: none;
  transition: transform 0.1s, box-shadow 0.15s;
  overflow: hidden;
  vertical-align: middle;
}
.card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}
.card.face-down {
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,0.10), transparent 50%),
    repeating-linear-gradient(45deg, #3d5a80, #3d5a80 5px, #2d4460 5px, #2d4460 10px);
  border: 1px solid var(--maroon-2);
}
.card.face-down::after {
  content: '';
  display: block;
  width: 100%;
  height: 100%;
}
.card.legal-good   { outline: 2px solid var(--good); }
.card.legal-neutral{ outline: 2px solid var(--gold); }
.card.legal-bad    { outline: 2px solid var(--bad); }
.card.chosen       { transform: translateY(-6px); box-shadow: 0 6px 16px rgba(61,90,128,0.35); }
.card.dimmed       { opacity: 0.35; }

.trick-center {
  background: var(--cream);
  border: 2px dashed var(--gold);
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  grid-template-columns: 70px 70px 70px;
  grid-template-rows: 90px 90px 90px auto;
  grid-template-areas:
    ".    n    ."
    "w    .    e"
    ".    s    ."
    "info info info";
  min-height: 300px;
  place-items: center;
  justify-content: center;
}
.slot-N { grid-area: n; }
.slot-S { grid-area: s; }
.slot-E { grid-area: e; }
.slot-W { grid-area: w; }
.trick-info {
  grid-area: info;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
  text-align: center;
  padding-top: 6px;
}
.trick-slot { min-height: 76px; min-width: 52px; display: flex; align-items: center; justify-content: center; }
.trick-slot .card.played-in {
  animation: play-drop 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes play-drop {
  0%   { opacity: 0; transform: scale(0.6) translateY(-14px) rotate(-6deg); }
  60%  { opacity: 1; transform: scale(1.08) translateY(2px) rotate(2deg); }
  100% { opacity: 1; transform: scale(1) translateY(0) rotate(0); }
}
.trick-slot .card.collecting {
  animation: collect-fly 0.9s ease-in-out forwards;
  z-index: 10;
  position: relative;
}
@keyframes collect-fly {
  0%   { transform: translate(0, 0) scale(1) rotate(0);
         opacity: 1; }
  35%  { transform: translate(var(--s1-dx, 0), var(--s1-dy, 0)) scale(1) rotate(0);
         opacity: 1; }
  50%  { transform: translate(var(--s1-dx, 0), var(--s1-dy, 0)) scale(1) rotate(var(--rot, 0deg));
         opacity: 1; }
  100% { transform: translate(var(--dx, 0), var(--dy, 0)) scale(0.5) rotate(var(--rot, 0deg));
         opacity: 0; }
}

/* Analysis panel */
.analysis {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-top: 14px;
}
.analysis h3 {
  margin: 0 0 10px 0;
  color: var(--maroon-2);
  font-family: var(--font-serif);
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 4px;
}
.opt-list { list-style: none; padding: 0; margin: 0; }
.opt-list li {
  display: grid;
  grid-template-columns: 60px 70px 1fr;
  gap: 10px;
  align-items: start;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line-soft);
  font-size: 14px;
}
.opt-list li:last-child { border-bottom: none; }
.opt-card {
  display: inline-block;
  width: 40px;
  height: 58px;
  background: #fff;
  border-radius: 5px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
  vertical-align: middle;
  overflow: hidden;
}
.opt-card img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.tag.good    { background: #dff0d8; color: var(--good); }
.tag.neutral { background: #fdf5d3; color: var(--gold-2); }
.tag.bad     { background: #f6dada; color: var(--bad); }

.recommended-badge {
  background: var(--gold);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  margin-left: 8px;
  letter-spacing: 0.5px;
}

.scorebar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 14px;
}
.score-box {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.s-name { font-family: var(--font-serif); color: var(--maroon-2); font-size: 14px; }
.s-val { font-family: var(--font-mono); font-size: 16px; font-weight: 700; }

.flash {
  margin: 10px 0 0;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  border-left: 4px solid var(--bad);
  background: #fbe7e7;
  color: var(--bad);
  animation: flash-in 0.25s ease-out;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.flash-img {
  flex: 0 0 auto;
  width: 90px;
  height: 90px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid rgba(0,0,0,0.15);
}
.flash-text { flex: 1; }
.flash.good  { border-left-color: var(--good); background: #e5f2e6; color: var(--good); }
.flash.info  { border-left-color: var(--gold); background: #fdf5d3; color: var(--gold-2); }
.flash.hidden { display: none; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.card.clickable { cursor: pointer; }
.card.clickable:hover {
  transform: translateY(-14px);
  box-shadow: 0 8px 18px rgba(61,90,128,0.30);
  z-index: 5;
  position: relative;
}
.card.hint-pulse {
  animation: pulse-hint 1.2s ease-in-out infinite;
  outline: 2px solid var(--gold);
}
@keyframes pulse-hint {
  0%, 100% { box-shadow: 0 0 0 0 rgba(184,145,42,0.4); }
  50%      { box-shadow: 0 0 0 6px rgba(184,145,42,0.0); }
}

.template-note {
  font-size: 13px;
  color: var(--ink-soft);
  background: var(--cream-2);
  padding: 10px 14px;
  border-radius: 8px;
  border-left: 3px solid var(--gold);
}

/* -------- Scoring calculator -------- */
.calc-doubles {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px;
  background: var(--cream-2);
  border-radius: 8px;
}
.calc-doubles label { font-size: 13px; }
.calc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.calc-table th, .calc-table td {
  border: 1px solid var(--line);
  padding: 8px;
  text-align: center;
}
.calc-table th {
  background: var(--cream-2);
  font-family: var(--font-serif);
  color: var(--maroon-2);
  font-weight: 600;
}
.calc-table input[type="checkbox"] { transform: scale(1.2); }
.calc-table input[type="number"] {
  width: 60px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--font-mono);
  text-align: center;
}
.calc-table td:last-child {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--maroon-2);
  background: var(--cream);
}
.tot-label { text-align: right !important; color: var(--ink-soft); font-style: italic; }

/* -------- Quick lessons / scenarios -------- */
.scenario {
  background: var(--cream);
  border: 1px solid var(--line);
  border-left: 4px solid var(--maroon);
  border-radius: 10px;
  padding: 14px 18px 18px;
  margin: 14px 0;
}
.scenario h3 {
  margin: 0 0 6px 0;
  color: var(--maroon-2);
  font-family: var(--font-serif);
}
.scenario .sc-intro {
  font-size: 14px;
  color: var(--ink-soft);
  margin: 0 0 10px;
}
.mini-frame {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.mini-table {
  background: #eee1bd;
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: 60px 60px 60px;
  grid-template-rows: 80px 80px 80px auto;
  grid-template-areas:
    ".    n    ."
    "w    .    e"
    ".    s    ."
    "info info info";
  place-items: center;
  justify-content: center;
  min-height: 260px;
  position: relative;
}
.mini-slot { min-width: 52px; min-height: 76px; display: flex; align-items: center; justify-content: center; }
.mini-slot-N { grid-area: n; }
.mini-slot-S { grid-area: s; }
.mini-slot-E { grid-area: e; }
.mini-slot-W { grid-area: w; }
.mini-slot .seat-tag {
  position: absolute;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--ink-soft);
  opacity: 0.7;
  margin-top: -30px;
}
.mini-info {
  grid-area: info;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
  padding-top: 4px;
}
.mini-hand {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 14px 0 6px;
  justify-content: center;
}
.mini-hand .card.locked { cursor: not-allowed; opacity: 0.4; }
.mini-answer {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--good);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 14px;
}
.mini-answer.wrong { border-left-color: var(--bad); }
.mini-answer p { margin: 6px 0; }
.mini-slot .card.played-in {
  animation: play-drop 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.mini-slot .card.collecting {
  animation: collect-fly 0.7s ease-in-out forwards;
  z-index: 10;
  position: relative;
}

.strat-intro {
  background: linear-gradient(90deg, #fdf6dd, #f6edc9);
  border-left: 4px solid var(--maroon);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 15px;
}

/* -------- Strategy grid -------- */
.strat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.strat-card {
  background: var(--cream);
  border: 1px solid var(--line);
  border-left: 4px solid var(--maroon);
  border-radius: 10px;
  padding: 14px 16px;
}
.strat-card h3 { margin-top: 0; }
.strat-card p { font-size: 14px; color: var(--ink-soft); margin-bottom: 0; }

/* -------- Glossary -------- */
.glossary { display: grid; grid-template-columns: 160px 1fr; gap: 8px 20px; }
.glossary dt { font-family: var(--font-serif); color: var(--maroon-2); font-weight: 700; }
.glossary dd { margin: 0; font-size: 14px; color: var(--ink-soft); }

/* -------- Footer -------- */
.site-footer {
  text-align: center;
  padding: 24px;
  color: var(--ink-soft);
  font-size: 15px;
  border-top: 1px solid var(--line-soft);
}
.footer-inner {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: center;
  max-width: 500px;
  margin: 0 auto;
}
.footer-img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 12px;
  border: 2px solid var(--line);
}
.site-footer p { margin: 0; font-family: var(--font-serif); color: var(--maroon-2); }

/* -------- Responsive -------- */
@media (max-width: 900px) {
  .penalty-grid { grid-template-columns: repeat(2, 1fr); }
  .table-wrap {
    grid-template-columns: 1fr;
    grid-template-areas:
      "north"
      "west"
      "center"
      "east"
      "south";
  }
  .hand-vert { min-height: auto; }
  .scorebar { grid-template-columns: repeat(2, 1fr); }
  .glossary { grid-template-columns: 1fr; }
  .brand-text h1 { font-size: 22px; }
}
