/* Taco Soda Pop — Rhythm Training Cards
   Palette: Marigold #F9CE42, Soft Mint #B8EBD0, Pastel Lavender #D4C4FB,
   Blush Pink #FFD6D6, Cream White #FFFDF7. Text uses a deep plum for contrast. */
:root {
  --marigold: #F9CE42;
  --mint: #B8EBD0;
  --lavender: #D4C4FB;
  --blush: #FFD6D6;
  --cream: #FFFDF7;
  --ink: #2B2540;
  --ink-soft: #5A5273;
  --line: rgba(43, 37, 64, .22);
  --stop: #D93B3B;
  --radius: 18px;
  --cols: 4;
  --cw: 196px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--cream); color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 17px; line-height: 1.5;
}
img { max-width: 100%; display: block; }
a { color: var(--ink); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--cream); padding: 8px 14px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }
.wrap { width: min(1180px, calc(100% - 32px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px))); margin-inline: auto; }

/* Header */
.site-header { background: var(--marigold); border-bottom: 3px solid var(--ink); padding-top: env(safe-area-inset-top, 0px); }
.site-header .wrap { display: flex; align-items: center; gap: 16px; padding: 14px 0; flex-wrap: wrap; }
.logo { width: 54px; height: 54px; }
.site-header h1 { margin: 0; font-size: clamp(1.35rem, 3.4vw, 2.1rem); line-height: 1.1; letter-spacing: .01em; }
.site-header p { margin: 2px 0 0; font-size: .98rem; }
.site-header nav { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.site-header nav a {
  text-decoration: none; font-weight: 700; padding: 8px 14px; border-radius: 999px;
  background: var(--cream); border: 2px solid var(--ink);
}
.site-header nav a:hover { background: var(--blush); }

/* Game layout: controls beside the board when there is room (landscape) */
.game { padding: 22px 0 8px; display: grid; gap: 20px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 900px) { .game { grid-template-columns: 300px 1fr; } }
.panel { background: var(--lavender); border: 3px solid var(--ink); border-radius: var(--radius); padding: 16px; }
.panel h2:not(.vh) { margin: 0 0 10px; font-size: 1.1rem; }
.btn-stack { display: grid; gap: 10px; }
.btn {
  font: inherit; font-weight: 800; font-size: 1.05rem; color: var(--ink);
  background: var(--marigold); border: 3px solid var(--ink); border-radius: 14px;
  padding: 12px 14px; min-height: 52px; cursor: pointer; box-shadow: 0 4px 0 var(--ink);
  transition: transform .08s, box-shadow .08s;
}
.btn:hover { background: #fbd95f; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.secondary { background: var(--mint); }
.btn.secondary:hover { background: #cbf2dd; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.rt-btn-stop, .btn.rt-btn-stop:hover { background: var(--stop); color: #fff; }
.settings { margin-top: 14px; }
details.settings > .field, details.settings > .check { margin: 14px 0 0; }
.settings summary {
  font-weight: 800; cursor: pointer; min-height: 46px; display: flex; align-items: center; gap: 10px;
  background: var(--cream); border: 2px solid var(--ink); border-radius: 12px; padding: 4px 14px; list-style: none;
}
.settings summary::-webkit-details-marker { display: none; }
.settings summary .hint { margin-left: auto; font-weight: 700; font-size: .85rem; color: var(--ink-soft); }
.settings summary::after { content: "\25BE"; font-size: 1.2rem; line-height: 1; transition: transform .15s; }
.settings[open] summary::after { transform: rotate(180deg); margin-left: auto; }
.settings[open] summary .hint { display: none; }
.settings[open] summary { margin-bottom: 4px; }
.settings summary:hover { background: var(--blush); }
.field > span, .field > legend { display: block; font-weight: 800; font-size: .9rem; margin-bottom: 6px; padding: 0; }
fieldset.field { border: 0; margin: 0; padding: 0; min-width: 0; }
.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1; font: inherit; font-weight: 800; color: var(--ink); background: var(--cream);
  border: 2px solid var(--ink); border-radius: 10px; padding: 8px 0; min-height: 44px; cursor: pointer;
}
.seg.seg-grid { flex-wrap: wrap; }
.seg.seg-grid button { flex: 1 1 28%; padding: 8px 4px; font-size: .92rem; }
.seg button[aria-pressed="true"] { background: var(--blush); box-shadow: inset 0 0 0 2px var(--ink); }
input[type=range] { width: 100%; accent-color: var(--ink); height: 32px; }
.tempo-val { font-weight: 800; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; }
.check input { width: 24px; height: 24px; accent-color: var(--ink); }

/* Board */
.board-wrap { background: var(--mint); border: 3px solid var(--ink); border-radius: var(--radius); padding: 16px; min-height: 120px; }
.board-status { margin: 0 0 12px; font-weight: 700; min-height: 1.5em; }
.board {
  display: grid; gap: 12px; justify-content: center;
  grid-template-columns: repeat(var(--cols), minmax(0, var(--cw)));
}
.slot { position: relative; }
.cardwrap { position: relative; }

/* Notation drawn above each card (the card art itself has none) */
.notation {
  background: var(--cream); color: var(--ink); border: 3px solid var(--ink); border-radius: 12px;
  margin-bottom: 8px; padding: 2px 0; transition: background .08s;
}
.notation svg { display: block; width: 100%; max-width: 112px; height: auto; margin: 0 auto; }
body.no-notation .notation { display: none; }
.slot.now .notation { background: var(--marigold); }
.gallery .notation { margin-bottom: 6px; border-width: 2px; border-radius: 10px; }
.gallery .notation svg { max-width: 84px; }
.gallery button.playing .notation { background: var(--marigold); }
.beat-num {
  position: absolute; top: -10px; left: -6px; z-index: 2; width: 30px; height: 30px; border-radius: 50%;
  background: var(--cream); border: 2px solid var(--ink); display: grid; place-items: center; font-weight: 800; font-size: .9rem;
}
.card-img { border: 3px solid var(--ink); border-radius: 12px; background: var(--cream); width: 100%; height: auto; aspect-ratio: 520 / 728; object-fit: cover; }
.slot.deal { animation: dealIn .35s ease both; }
.slot.swap { animation: swapIn .22s ease both; }
@keyframes swapIn { from { opacity: .2; transform: scale(.96); } to { opacity: 1; transform: none; } }
.mode-field { margin-bottom: 14px !important; }
.mode-note { margin: 6px 0 0; font-size: .85rem; color: var(--ink-soft); line-height: 1.35; }
@media (max-width: 600px) { .mode-note { display: none; } .mode-field { margin-bottom: 10px !important; } }
.slot.now .card-img { outline: 6px solid var(--marigold); outline-offset: 2px; transform: scale(1.05); box-shadow: 0 8px 0 var(--ink); }
.slot.now .beat-num { background: var(--marigold); }
.slot .card-img { transition: transform .08s; }
@keyframes dealIn { from { opacity: 0; transform: translateY(-14px) rotate(-3deg); } to { opacity: 1; transform: none; } }
.empty { text-align: center; }
.empty img { width: min(260px, 60%); margin: 0 auto 12px; border: 3px solid var(--ink); border-radius: 14px; }
/* The food names are on the cards already; the line stays for screen readers only */
.names { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; }

/* Expert mode: one big card fills the board */
.board.expert { grid-template-columns: minmax(0, 1fr); }
.xslot { position: relative; }
.xcard { background: var(--cream); border: 3px solid var(--ink); border-radius: 16px; padding: clamp(10px, 2.2vw, 24px); position: relative; }
.xnum { position: absolute; top: 6px; right: 12px; font-size: .78rem; font-weight: 700; color: var(--ink-soft); }
.xnote svg { display: block; width: 100%; height: auto; color: var(--ink); }
.xnote .bz { fill: transparent; transition: fill .08s; }
.xnote .bz.now { fill: var(--marigold); }
body.no-notation .xnote { display: none; }
.xtext { margin: 4px 0 0; text-align: center; font-weight: 800; font-size: clamp(1.5rem, 5vw, 3.1rem); line-height: 1.15; white-space: pre-line; text-wrap: balance; }
.xtext:empty { display: none; }
body.mode-expert #field-ts, body.mode-expert #chk-triplet { display: none; }
@media (orientation: landscape) and (max-height: 520px) { .xtext { font-size: clamp(1.2rem, 6vh, 2.2rem); } }
h3.sub { margin: 26px 0 4px; font-size: 1.25rem; }
.xgallery { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin-top: 10px; }
.xgallery button { font: inherit; color: var(--ink); background: var(--cream); border: 3px solid var(--ink); border-radius: 14px; padding: 6px 8px 8px; cursor: pointer; text-align: center; }
.xgallery button:hover { background: var(--blush); }
.xgallery button.playing { outline: 5px solid var(--marigold); }
.xgallery .xnote svg { max-width: 100%; }
.xgallery .xid { display: block; text-align: right; font-size: .75rem; font-weight: 700; color: var(--ink-soft); }
.xg-title { margin: 26px 0 0; font-size: 1.15rem; }
.xgallery span { display: block; font-weight: 700; font-size: .95rem; white-space: pre-line; min-height: 1.4em; }


/* Info sections */
section.info { padding: 14px 0; }
details.deck { margin: 18px 0; }
.deck summary {
  display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none;
  background: var(--cream); border: 3px solid var(--ink); border-radius: 14px;
  padding: 14px 16px; font-weight: 800; font-size: 1.15rem;
}
.deck summary::-webkit-details-marker { display: none; }
.deck summary .hint { margin-left: auto; font-weight: 700; font-size: .85rem; color: var(--ink-soft); text-align: right; }
.deck summary::after { content: "\25BE"; font-size: 1.2rem; line-height: 1; transition: transform .15s; }
.deck[open] summary::after { transform: rotate(180deg); }
.deck summary:hover { background: var(--blush); }
.deck .gallery { margin-top: 14px; }
@media (max-width: 600px) { .deck summary .hint { display: none; } }
section.info h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); margin: 0 0 12px; }
.two { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 800px) { .two { grid-template-columns: 1fr 1fr; } }
.two.one { grid-template-columns: 1fr; }
.note-card { border: 3px solid var(--ink); border-radius: var(--radius); padding: 18px 22px; }
.note-card.yellow { background: var(--marigold); }
.note-card.pink { background: var(--blush); }
.note-card.lav { background: var(--lavender); }
.note-card h3 { margin: 0 0 8px; }
.note-card ol, .note-card ul { margin: 0; padding-left: 1.3em; }
.note-card li { margin: 4px 0; font-weight: 700; }

/* Gallery */
.gallery { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.gallery button { padding: 0; border: 0; background: none; cursor: pointer; text-align: center; font: inherit; color: var(--ink); display: flex; flex-direction: column; justify-content: flex-start; align-self: start; }
.gallery .card-img { transition: transform .12s; }
.gallery button:hover .card-img { transform: translateY(-4px) rotate(-1deg); }
.gallery .unlock-card { grid-column: span 1; align-self: stretch; }
.unlock-face {
  display: flex !important; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  height: 100%; min-height: 220px; padding: 14px 10px; margin: 0 !important; text-align: center;
  background: var(--marigold); border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 4px 0 var(--ink);
  font-size: 1rem !important; transition: transform .12s;
}
.unlock-card:hover .unlock-face { transform: translateY(-4px) rotate(-1deg); }
.unlock-face svg { width: 44px; height: 44px; color: var(--ink); }
.unlock-face strong { font-size: 1.05rem; line-height: 1.15; }
.unlock-face em { font-style: normal; font-weight: 700; font-size: .8rem; }
.gallery span { display: block; font-size: .85rem; font-weight: 700; margin-top: 4px; }
.gallery button.playing .card-img { outline: 5px solid var(--marigold); }

footer { margin-top: 30px; background: var(--lavender); border-top: 3px solid var(--ink); padding: 22px 0 34px; }
footer .wrap { display: flex; gap: 14px 28px; flex-wrap: wrap; justify-content: space-between; }
footer p { margin: 0; max-width: 60ch; font-size: .95rem; }

.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Phones: slightly smaller cards, tighter chrome */
@media (max-width: 600px) {
  body { font-size: 16px; }
  .site-header .wrap { padding: 10px 0; gap: 4px 12px; }
  .logo { width: 38px; height: 38px; }
  .site-header p { font-size: .85rem; }
  .site-header nav { width: 100%; gap: 6px; }
  .site-header nav a { padding: 5px 10px; font-size: .9rem; }
  .game { padding-top: 14px; gap: 14px; }
  .btn-stack { grid-template-columns: 1fr 1fr; }
  .panel h2 { display: none; }
  .settings { margin-top: 8px; }
  .board { gap: 8px; }
  .board-wrap, .panel { padding: 12px; }
  .site-header nav { margin-left: 0; }
}
/* Short landscape screens: keep the game above the fold */
@media (orientation: landscape) and (max-height: 520px) {
  .site-header .wrap { padding: 8px 0; }
  .logo { width: 36px; height: 36px; }
  .site-header p { display: none; }
}
/* Empty outlines shown before the first deal */
.notation.ph { border-style: dashed; border-color: rgba(43, 37, 64, .35); background: rgba(255, 253, 247, .55); }
.notation.ph svg { visibility: hidden; }
.card-img.ph-card { border-style: dashed; border-color: rgba(43, 37, 64, .35); background: rgba(255, 253, 247, .55); display: grid; place-items: center; font-size: 2.6rem; color: rgba(43, 37, 64, .22); }
.xcard.ph { border-style: dashed; border-color: rgba(43, 37, 64, .35); background: rgba(255, 253, 247, .55); min-height: 220px; display: grid; place-items: center; align-content: center; text-align: center; color: rgba(43, 37, 64, .4); }
.xcard.ph span { font-size: 3rem; line-height: 1; }
.xcard.ph p { margin: 6px 0 0; font-weight: 800; }

/* Phone held upright: two rows of two bigger cards, and Shuffle / Play stay pinned to the bottom of the screen */
.rotate-hint { display: none; margin: 0 0 10px; font-size: .9rem; font-weight: 700; color: var(--ink-soft); }
@media (max-width: 600px) and (orientation: portrait) {
  .board:not(.expert) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
  .board:not(.expert) .slot { max-width: min(190px, calc((100vh - 190px) / 3.95)); width: 100%; justify-self: center; }
  .board-wrap { scroll-margin-top: 8px; }
  .notation { margin-bottom: 6px; border-width: 2px; }
  .notation svg { max-width: 96px; }
  .btn-stack {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; gap: 10px;
    padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
    background: var(--lavender); border-top: 3px solid var(--ink);
  }
  body { padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px)); }
  body.mode-expert .rotate-hint { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Expert count-in label above the next card */
.xcount { text-align: center; font-weight: 800; font-size: 1.15rem; margin: 0 0 8px; color: var(--ink, #2b2540); }

/* "Install as an app" hint (phones only, shown by js/pwa.js) */
.install-hint { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--lavender); border-bottom: 3px solid var(--ink); font-size: .95rem; }
.install-hint p { margin: 0; flex: 1; line-height: 1.35; }
.install-hint button { font: inherit; font-weight: 800; color: var(--ink); background: #FFFDF7; border: 2px solid var(--ink); border-radius: 10px; padding: 6px 12px; cursor: pointer; }
.install-hint .ih-x { font-size: 1.3rem; line-height: 1; padding: 2px 10px; }

/* Installed on a phone: keep the status-bar area a solid yellow so nothing shows blurred through it */
body::before { content: ""; position: fixed; top: 0; left: 0; right: 0; height: env(safe-area-inset-top, 0px); background: var(--marigold); z-index: 50; pointer-events: none; }

/* Installed app: iOS softens the strip just below the status bar, so give the title a little more room beneath it */
@media (display-mode: standalone) {
  .site-header { padding-top: calc(env(safe-area-inset-top, 0px) + 14px); }
}

/* Cards built from vector art: picture over a palette colour, with the name as live text */
.card-img.face { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7%; padding: 6% 5%; container-type: inline-size; overflow: hidden; }
.face-art { width: 80%; height: auto; aspect-ratio: 1; flex: none; }
.face-name { font-weight: 800; font-size: 18cqw; line-height: 1.05; letter-spacing: -.01em; text-align: center; color: var(--ink); text-wrap: balance; }
.face-name.long { font-size: 15cqw; }
.card-img.bg-marigold { background: var(--marigold); } .card-img.bg-mint { background: var(--mint); }
.card-img.bg-lavender { background: var(--lavender); } .card-img.bg-blush { background: var(--blush); }
.card-img.bg-sky { background: #BFE3F5; }
.gallery button:has(.face) > span { display: none; }  /* the name is already on the card */

.unlock-face small { font-size: .72rem; font-weight: 700; opacity: .75; }
.unlock-form input { width: 90%; max-width: 12rem; font: inherit; font-weight: 800; text-align: center; text-transform: uppercase; letter-spacing: .08em; padding: .45rem .5rem; border: 2px solid var(--ink); border-radius: 10px; background: #FFFDF7; color: var(--ink); }
.unlock-form .btn { padding: .45rem 1.1rem; }
.gallery .unlock-card button.unlock-face { width: 100%; background: var(--marigold); color: var(--ink); border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 4px 0 var(--ink); cursor: pointer; font-family: inherit; }
.unlock-form .btn { background: var(--ink); color: #FFFDF7; border: 0; box-shadow: none; cursor: pointer; font-weight: 800; border-radius: 999px; }
.xgallery[hidden], .xg-title[hidden] { display: none; }
.gallery .face-name.long { font-size: .85rem; }  /* in the deck view every name uses the same size */
