/* FreeCell: deep teal felt, four free cells and four foundations across the top, eight columns.
   Card size comes from --cw, set by freecell.js from the board width. */
.fc-page { --cb-felt-1: #1b6b75; --cb-felt-2: #0c3140; --fc-gold: #ffd166; }
.fc-page [hidden] { display: none !important; }

.fc-hero { margin-bottom: 10px; }
.fc-hero .cbx-sub { margin: 0; }

.fc-modes { display: flex; gap: 6px; margin: 0 0 10px; background: var(--cbx-soft); padding: 4px; border-radius: 14px; }
.fc-modes button { flex: 1; border: 0; background: transparent; padding: 10px 6px; border-radius: 11px; font: 900 15px var(--cbx-body); color: var(--cbx-muted); cursor: pointer; white-space: nowrap; }
.fc-modes button[aria-selected="true"] { background: #fff; color: var(--cbx-ink); box-shadow: 0 2px 6px rgba(42, 29, 23, .12); }
.fc-tick { color: var(--cbx-accent); }

.fc-card { padding: 10px; }
.fc-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.fc-top-r { display: flex; align-items: center; gap: 8px; }
.fc-pill { font: 900 13px var(--cbx-body); background: color-mix(in srgb, var(--cbx-accent) 12%, #fff); color: color-mix(in srgb, var(--cbx-accent) 70%, #000); padding: 6px 11px; border-radius: 999px; }
.fc-score { font: 800 14px var(--cbx-body); color: var(--cbx-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fc-score b { color: var(--cbx-ink); font-weight: 900; }
.fc-icon { border: 0; background: var(--cbx-soft); width: 36px; height: 34px; border-radius: 10px; font-size: 17px; cursor: pointer; }

.fc-card .fc-challenge { margin: 0 0 8px; padding: 10px 12px; border-radius: 14px; background: #fff4e6; box-shadow: inset 0 0 0 2px #f6c58f; font: 800 15px/1.35 var(--cbx-body); color: #5a3510; }
.fc-card .fc-challenge b { color: #c25e00; }

/* ---- the table ---- */
.fc-board {
  --gap: 6px; --tab-h: 420px;
  position: relative; border-radius: 16px; padding: 10px 8px 12px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08), inset 0 10px 30px rgba(0, 0, 0, .25);
  user-select: none; -webkit-user-select: none; overflow: hidden;
}
.fc-row { display: grid; grid-template-columns: repeat(8, var(--cw)); gap: var(--gap); justify-content: center; }
.fc-row#topRow { padding-bottom: 12px; margin-bottom: 10px; border-bottom: 1px solid rgba(255, 255, 255, .1); }
.fc-pile { position: relative; width: var(--cw); height: calc(var(--cw) * 1.4); border-radius: calc(var(--cw) * .1); }
.fc-pile > .cb-card { position: absolute; left: 0; top: 0; }
.fc-pile .cb-slot { position: absolute; inset: 0; }
.fc-col { height: var(--tab-h); }
.fc-col > .cb-slot.fc-empty { height: calc(var(--cw) * 1.4); bottom: auto; background: rgba(0, 0, 0, .12); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .16); }

/* free cells: dashed and empty-looking; foundations: solid with a big suit */
.fc-cell .cb-slot { background: rgba(0, 0, 0, .18); box-shadow: none; outline: 2px dashed rgba(255, 255, 255, .35); outline-offset: -3px; border-radius: inherit; }
.fc-home .cb-slot { background: rgba(255, 255, 255, .07); box-shadow: inset 0 0 0 2px rgba(255, 216, 120, .55); }
.fc-home .cb-slot span { font: 900 calc(var(--cw) * .55)/1 Nunito, sans-serif; color: rgba(255, 230, 170, .55); }
.fc-home .cb-slot.fc-h span, .fc-home .cb-slot.fc-d span { color: rgba(255, 170, 170, .6); }
.fc-home:nth-child(5) { margin-left: 0; }

/* bigger, side-by-side corner index so small overlapped cards stay readable */
.fc-board .cb-card .cc-i, .fc-ghost .cb-card .cc-i { flex-direction: row; align-items: baseline; gap: 0; left: 6%; top: 3%; }
.fc-board .cb-card .cc-i b, .fc-ghost .cb-card .cc-i b { font-size: calc(var(--w) * .32); }
.fc-board .cb-card .cc-i i, .fc-ghost .cb-card .cc-i i { font-size: calc(var(--w) * .27); }
.fc-board .cb-card .cc-b, .fc-ghost .cb-card .cc-b { left: auto; top: auto; }
.fc-board .cb-card .cc-c, .fc-ghost .cb-card .cc-c { top: 18%; }
.fc-board .cb-card.face .cc-c, .fc-ghost .cb-card.face .cc-c { inset: 30% 16% 16%; }

.fc-board .cb-card, .fc-ghost .cb-card { touch-action: none; }
.fc-board .cb-card.fc-homecard { cursor: default; }
.fc-board .cb-card.hint { box-shadow: 0 0 0 3px var(--fc-gold), 0 0 14px rgba(255, 209, 102, .85); }
.fc-pile.fc-target::after, .fc-pile.fc-over::after {
  content: ''; position: absolute; left: -3px; right: -3px; top: -3px; height: calc(var(--cw) * 1.4 + 6px);
  border-radius: calc(var(--cw) * .12); box-shadow: 0 0 0 3px var(--fc-gold), 0 0 18px rgba(255, 209, 102, .6); pointer-events: none; z-index: 300;
}
.fc-col.fc-target::after, .fc-col.fc-over::after { top: auto; bottom: auto; height: auto; top: -3px; bottom: -3px; background: rgba(255, 209, 102, .07); }
.fc-pile.fc-target::after { animation: fc-pulse 1s ease-in-out infinite; }
@keyframes fc-pulse { 50% { opacity: .45; } }

.fc-ghost { position: fixed; inset: 0; pointer-events: none; z-index: 1000; }
.fc-ghost .cb-card { box-shadow: 0 0 0 1px var(--cb-card-edge), 0 10px 22px rgba(0, 0, 0, .35); }

.fc-won .fc-home .cb-card { animation: fc-hop .6s ease-out both; }
.fc-won .fc-home:nth-child(6) .cb-card { animation-delay: .1s; }
.fc-won .fc-home:nth-child(7) .cb-card { animation-delay: .2s; }
.fc-won .fc-home:nth-child(8) .cb-card { animation-delay: .3s; }
@keyframes fc-hop { 40% { transform: translateY(-14px) rotate(-3deg); } 70% { transform: translateY(2px); } }

.fc-board .fc-toast { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -6px); width: max-content; max-width: 86%; padding: 10px 14px; border-radius: 12px; background: rgba(12, 22, 34, .92); color: #fff; font: 900 15px/1.3 var(--cbx-body); text-align: center; box-shadow: 0 10px 24px rgba(0, 0, 0, .35); opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; z-index: 900; }
.fc-board .fc-toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---- controls ---- */
.fc-stuck { margin: 10px 0 0; padding: 12px; border-radius: 14px; background: #fff4e6; box-shadow: inset 0 0 0 2px #f6c58f; text-align: center; }
.fc-card .fc-stuck p { margin: 0 0 10px; font: 800 15px/1.35 var(--cbx-body); color: #5a3510; }
.fc-stuck-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.fc-stuck-btns .cbx-btn { min-height: 44px; padding: 8px 16px; font-size: 15px; }

.fc-tools { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 10px; }
.fc-tool { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 52px; padding: 6px 2px; border: 0; border-radius: 13px; background: var(--cbx-soft); color: var(--cbx-ink); font: 900 13px var(--cbx-body); cursor: pointer; box-shadow: 0 2px 0 var(--cbx-line); -webkit-tap-highlight-color: transparent; white-space: nowrap; }
.fc-tool span { font-size: 18px; line-height: 1.1; }
.fc-tool:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.fc-tool:disabled { opacity: .4; cursor: default; }
.fc-tool.busy span { animation: fc-pulse .7s ease-in-out infinite; }

.fc-auto { display: inline-flex; align-items: center; gap: 8px; margin: 10px 2px 0; font: 800 13px/1.3 var(--cbx-body); color: var(--cbx-ink-2); cursor: pointer; user-select: none; }
.fc-auto input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.fc-switch { flex: none; width: 34px; height: 20px; border-radius: 999px; background: #d9cfc4; position: relative; transition: background .15s; }
.fc-switch::after { content: ''; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.fc-auto input:checked + .fc-switch { background: var(--cbx-accent); }
.fc-auto input:checked + .fc-switch::after { transform: translateX(14px); }
.fc-auto input:focus-visible + .fc-switch { outline: 3px solid color-mix(in srgb, var(--cbx-accent) 45%, transparent); outline-offset: 2px; }

/* ---- result ---- */
.fc-result { margin-top: 14px; padding-top: 14px; border-top: 2px dashed var(--cbx-line); }
.fc-card .fc-res-line { margin: 4px 0 12px; font: 800 16px/1.4 var(--cbx-body); color: var(--cbx-ink-2); }
.fc-card .fc-res-line b { color: var(--cbx-ink); }
.fc-card .fc-vs { margin: -2px 0 14px; padding: 10px 12px; border-radius: 14px; background: var(--cbx-soft); font: 900 17px/1.35 var(--cbx-body); color: var(--cbx-ink); text-align: center; }
.fc-card .fc-vs.win { background: #e2f4f2; color: #0b5d63; }
.fc-mini, .fc-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0 0 14px; }
.fc-mini div, .fc-nums div { background: var(--cbx-soft); border-radius: 12px; padding: 8px 4px; text-align: center; }
.fc-mini b, .fc-nums b { display: block; font: 900 22px var(--cbx-body); color: var(--cbx-ink); font-variant-numeric: tabular-nums; }
.fc-mini span, .fc-nums span { display: block; font: 800 11px var(--cbx-body); color: var(--cbx-muted); text-transform: uppercase; letter-spacing: .04em; }
.fc-name { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font: 900 13px var(--cbx-body); color: var(--cbx-muted); text-transform: uppercase; letter-spacing: .04em; }
.fc-name input { flex: 1; min-width: 0; padding: 9px 12px; border-radius: 12px; border: 2px solid var(--cbx-line); font: 800 16px var(--cbx-body); color: var(--cbx-ink); text-transform: none; letter-spacing: 0; background: #fff; }
.fc-result #resShare2 { margin-top: 8px; }
.fc-link { display: block; margin: 8px auto 0; border: 0; background: none; padding: 8px; font: 900 15px var(--cbx-body); color: color-mix(in srgb, var(--cbx-accent) 85%, #000); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ---- dialogs (top layer: page variables are on body, so they still reach) ---- */
.fc-dlg { border: 0; padding: 0; border-radius: 22px; width: min(420px, calc(100vw - 32px)); box-shadow: 0 30px 80px rgba(0, 0, 0, .35); color: #2a1d17; }
.fc-dlg::backdrop { background: rgba(12, 30, 40, .5); }
.fc-dlg-card { padding: 20px; }
.fc-dlg h2 { margin: 0 0 12px; font: 900 22px Fraunces, Georgia, serif; color: #2a1d17; }
.fc-dlg .fc-dlg-sub { margin: -6px 0 14px; font: 800 14px/1.4 Nunito, sans-serif; color: #7d685c; }
.fc-dlg .fc-nums { margin: 0; }
.fc-dlg .fc-nums b { font-size: 20px; }
.fc-field { display: grid; gap: 6px; font: 900 13px Nunito, sans-serif; color: #7d685c; text-transform: uppercase; letter-spacing: .04em; }
.fc-field input { padding: 12px 14px; border-radius: 12px; border: 2px solid #eadccb; font: 900 20px Nunito, sans-serif; color: #2a1d17; }
.fc-dlg .fc-dlg-err { margin: 8px 0 0; font: 800 14px Nunito, sans-serif; color: #b3261e; }
.fc-dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.fc-dlg .cbx-btn { min-height: 46px; padding: 10px 18px; }

/* ---- phones: give the cards every pixel ---- */
@media (max-width: 480px) {
  .fc-page .cbx-wrap { padding-left: 10px; padding-right: 10px; }
  .fc-card { padding: 8px 4px 12px; border-radius: 18px; }
  .fc-top, .fc-card .fc-challenge, .fc-tools, .fc-auto, .fc-stuck, .fc-result { margin-left: 4px; margin-right: 4px; }
  .fc-board { padding: 8px 4px 10px; border-radius: 12px; }
  .fc-row#topRow { padding-bottom: 8px; margin-bottom: 8px; }
  .fc-tool { font-size: 12px; min-height: 50px; }
  .fc-pill { font-size: 12px; padding: 5px 9px; }
  .fc-score { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .fc-pile.fc-target::after, .fc-won .fc-home .cb-card, .fc-tool.busy span { animation: none; }
  .fc-board .fc-toast { transition: none; }
}
