/* Hong Kong Mahjong Points page — tile components, faan tables, calculator.
   Builds on the shared design tokens defined in styles.css. */

/* ---- Section helpers ---- */
.points-section { padding: 3rem 0; }

#calculator.points-section { background: var(--color-surface); }

#basics.points-section { background: var(--color-background); }
#scoring.points-section { background: var(--color-surface); }
#special.points-section { background: var(--color-background); }
#payout.points-section { background: var(--color-surface); }

#basics .section-intro {
  margin-bottom: 1rem;
}

#basics .section-heading {
  margin-bottom: 0.35rem;
}

.points-lead {
  max-width: 65ch;
  margin: 0 auto 2rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 1rem;
}

/* ---- Tile component ---- */
.tile-face {
  display: block;
  aspect-ratio: 5 / 7;
  background: linear-gradient(160deg, #ffffff 0%, #fbf3e7 100%);
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12), inset 0 -2px 0 rgba(0, 0, 0, 0.05);
  padding: 9% 8% 6% 8%;
  overflow: hidden;
}

.tile-face img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center 53%;
}

/* ---- Faan tables ---- */
.faan-block { margin-bottom: 2rem; }

.faan-block h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  color: var(--color-primary);
  margin-bottom: 0.85rem;
}

.faan-table-wrap {
  overflow: hidden;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--color-surface);
}

.faan-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.97rem;
}

.faan-table th,
.faan-table td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  vertical-align: top;
}

.faan-table th {
  background: var(--color-primary);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 600;
  white-space: nowrap;
}

.faan-table th:first-child {
  border-radius: var(--radius) 0 0 0;
}

.faan-table th:last-child {
  border-radius: 0 var(--radius) 0 0;
}

.faan-table tbody tr:last-child td {
  border-bottom: none;
}

.faan-table tbody tr:last-child td:first-child {
  border-bottom-left-radius: var(--radius);
}

.faan-table tbody tr:last-child td:last-child {
  border-bottom-right-radius: var(--radius);
}

.faan-table td:first-child,
.faan-table th:first-child {
  white-space: nowrap;
}

.faan-table tbody tr:hover { background: rgba(var(--color-primary-rgb), 0.03); }

.faan-name { color: var(--color-text); font-size: 0.85rem; }
.faan-cn { color: var(--color-text-muted); font-weight: 500; }

.faan-value {
  color: var(--color-primary);
  white-space: nowrap;
}

.faan-limit { color: var(--color-secondary); }

.faan-desc { color: var(--color-text-muted); font-size: 0.92rem; }

.points-note {
  margin: 1.5rem auto 0 auto;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  font-style: italic;
  text-align: center;
  max-width: 61rem;
}

.points-note em {
  color: var(--color-primary);
}

/* ---- Payout table (compact) ---- */
.payout-table {
  max-width: 40rem;
  margin: 0 auto;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.payout-table .faan-table-wrap {
  overflow: visible;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

.payout-faan-table {
  table-layout: fixed;
  width: 100%;
  border-collapse: collapse;
  border-radius: 0;
  overflow: visible;
  box-shadow: none;
  background: var(--color-surface);
  border: none;
}

.payout-faan-table .payout-col {
  width: calc(100% / 3);
}

.payout-faan-table.faan-table th,
.payout-faan-table.faan-table td {
  text-align: center;
  white-space: normal;
  border: 0;
  background-clip: padding-box;
}

.payout-faan-table thead tr {
  background-color: var(--color-primary);
  position: relative;
}

.payout-faan-table.faan-table th {
  background-color: transparent;
}

.payout-faan-table tbody tr {
  background-color: var(--color-surface);
  position: relative;
}

.payout-faan-table thead tr::after,
.payout-faan-table tbody tr:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: rgba(0, 0, 0, 0.06);
  pointer-events: none;
}

.payout-faan-table.faan-table tbody td {
  background-color: transparent;
}

.payout-faan-table tbody tr:hover {
  background-color: rgba(var(--color-primary-rgb), 0.03);
}

.payout-faan-table tbody tr:hover td {
  background-color: transparent;
}

.payout-faan-table tbody tr:last-child td {
  border-bottom: none;
}

.payout-faan-table .faan-value {
  white-space: normal;
}

.payout-faan-table .payout-faan-num {
  color: var(--color-text);
}

/* ---- Calculator ---- */
#calculator,
#calculator button,
#calculator input,
#calculator label,
#calculator .palette-tile {
  touch-action: manipulation;
}

#calculator .hand-tile {
  touch-action: none;
}

.calc {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .calc {
    grid-template-columns: 1.1fr 0.9fr;
    align-items: stretch;
  }

  .calc-left .calc-card:last-child {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .calc-left .calc-card:last-child .calc-hand {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .calc-left .calc-card:last-child .hand-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 5.75rem;
  }

  .calc-left .calc-card:last-child .hand-placeholder {
    flex: 1;
    min-height: 5.75rem;
  }

  .calc-right .calc-card {
    height: 100%;
  }
}

.calc-left,
.calc-right {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.calc-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  border-top: 4px solid var(--color-primary);
}

.calc-card h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  color: var(--color-primary);
  margin: 0;
}

.calc-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.calc-card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.calc-card > h3 {
  margin-bottom: 1rem;
}

.calc-reset {
  flex-shrink: 0;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: var(--color-background);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}

.calc-reset:active:not(:disabled) { transform: scale(0.96); }

.calc-reset:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.calc-reset:disabled {
  opacity: 0.62;
  cursor: not-allowed;
  pointer-events: none;
}

.calc-reset:disabled:hover {
  background: var(--color-background);
  border-color: rgba(0, 0, 0, 0.2);
  color: var(--color-text-muted);
}

.calc-reset:active:not(:disabled) { transform: scale(0.96); }

.calc-reset.is-active,
.calc-reset.is-active:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.calc-reset.is-share-ready,
.calc-reset.is-share-ready:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
  animation: calc-share-pulse 1.6s ease-in-out infinite;
}

@keyframes calc-share-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(var(--color-primary-rgb), 0.55);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(var(--color-primary-rgb), 0), 0 0 16px rgba(var(--color-primary-rgb), 0.45);
    transform: scale(1.04);
  }
}

/* Hand area */
.calc-hand { min-height: 0; }

.hand-body {
  min-height: 7.75rem;
}

.hand-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.6rem;
}

.hand-meta-flowers { color: var(--color-accent); font-weight: 600; }

.hand-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 7.75rem;
  margin: 0;
  padding: 0.85rem 1rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.92rem;
  line-height: 1.45;
  background: var(--color-background);
  border-radius: var(--radius);
  border: 1px dashed rgba(0, 0, 0, 0.1);
}

.hand-tiles {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.hand-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 46px;
  padding: 0;
  border: none;
  background: none;
  cursor: grab;
  transition: transform 0.12s;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  -webkit-tap-highlight-color: transparent;
}

.hand-tiles--dragging {
  user-select: none;
}

.hand-tile.is-dragging-absolute {
  position: fixed;
  z-index: 1000;
  margin: 0;
  flex: none;
  cursor: grabbing;
  transition: none;
  animation: none;
  opacity: 0.96;
  transform: scale(1.05);
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.2));
  will-change: transform, left, top;
  pointer-events: none;
}

.hand-tiles--dragging .hand-tile:not(.is-dragging-absolute) {
  transition: none;
}

.hand-tile-placeholder {
  display: block;
  flex: 0 0 auto;
  box-sizing: border-box;
  border-radius: 12px;
  border: 2px dashed rgba(var(--color-primary-rgb), 0.35);
  background: rgba(var(--color-primary-rgb), 0.06);
  pointer-events: none;
  transition: none;
}

.hand-tile.is-just-added,
.hand-tile.is-removing {
  transition: none;
}

.hand-tile.is-removing-absolute {
  position: absolute;
  z-index: 2;
  margin: 0;
  flex: 0 0 auto;
}

.hand-tile.is-shifting {
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.hand-tile.is-shifting.is-shift-from {
  transition: none;
  transform: translate3d(var(--shift-x, 0), var(--shift-y, 0), 0);
}

.hand-tile .tile-face,
.palette-tile .tile-face {
  width: 100%;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
}

.hand-tile.is-flower .tile-face { border-color: var(--color-accent); }

@media (hover: hover) and (pointer: fine) {
  .hand-tile:hover { transform: translate3d(0, -3px, 0); }
}

/* Example + reset controls */
.calc-controls.is-hidden,
#calc-examples[hidden] {
  display: none !important;
}

.calc-card-head:has(+ #calc-examples[hidden]) {
  margin-bottom: 0;
}

.calc-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 0;
  margin-bottom: 1rem;
}

.calc-controls button {
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(var(--color-primary-rgb), 0.25);
  background: var(--color-background);
  color: var(--color-primary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.12s, box-shadow 0.12s, border-color 0.12s;
  width: 100%;
  text-align: center;
}

.calc-controls button:active { transform: scale(0.96); }

.calc-controls button:hover { background: var(--color-primary); color: #fff; }

.calc-controls button.is-active,
.calc-controls button.is-active:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.calc-controls button.is-flash-success,
.calc-reset.is-flash-success {
  animation: calc-btn-success 0.42s ease-out;
}

.calc-controls button.is-flash-rejected,
.calc-reset.is-flash-rejected {
  animation: calc-btn-rejected 0.45s ease-out;
}

.opt-check.is-flash-success {
  animation: opt-check-flash 0.36s ease-out;
}

@keyframes calc-btn-success {
  0% {
    transform: scale(0.93);
    box-shadow: 0 0 0 0 rgba(var(--color-primary-rgb), 0.75), 0 0 0 0 rgba(var(--color-primary-rgb), 0.4);
  }
  35% {
    transform: scale(1.045);
    box-shadow: 0 0 0 7px rgba(var(--color-primary-rgb), 0), 0 0 14px rgba(var(--color-primary-rgb), 0.45);
  }
  100% {
    transform: scale(1);
    box-shadow: none;
  }
}

@keyframes calc-btn-rejected {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); border-color: #c0392b; box-shadow: 0 0 0 2px rgba(192, 57, 43, 0.35); }
  40% { transform: translateX(5px); border-color: #c0392b; box-shadow: 0 0 0 2px rgba(192, 57, 43, 0.35); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

@keyframes opt-check-flash {
  0% { background: rgba(var(--color-primary-rgb), 0.16); }
  100% { background: transparent; }
}

/* Palette */
.palette-group { margin-bottom: 1rem; }

.palette-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-muted);
  margin: 0.45rem 0 0.45rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.palette-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.palette-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  width: 45px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  transition: transform 0.12s;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  -webkit-tap-highlight-color: transparent;
}

.palette-tile-mark {
  font-size: 1rem;
  font-weight: 400;
  color: var(--color-primary);
  line-height: 1.1;
  margin-top: 0.5rem;
}

.palette-tile.is-flash-success,
.palette-tile.is-flash-rejected {
  transition: none;
}

@media (hover: hover) and (pointer: fine) {
  .palette-tile:hover { transform: translate3d(0, -3px, 0); }
  .palette-tile:active { transform: translate3d(0, 0, 0) scale(0.94); }
}

.palette-tile.is-flash-success {
  animation: tile-palette-added 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.palette-tile.is-flash-success .tile-face {
  animation: tile-face-ripple 0.36s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.palette-tile.is-flash-rejected {
  animation: tile-palette-rejected 0.42s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.palette-tile.is-flash-rejected .tile-face {
  animation: tile-face-rejected 0.42s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.hand-tile.is-just-added {
  animation: tile-hand-enter 0.38s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.hand-tile.is-just-added .tile-face {
  animation: tile-face-ripple 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.hand-tile.is-removing {
  animation: tile-hand-exit 0.32s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  pointer-events: none;
}

@keyframes tile-hand-exit {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.82);
  }
}

@keyframes tile-palette-added {
  from {
    transform: translate3d(0, 0, 0) scale(0.92);
  }
  50% {
    transform: translate3d(0, 0, 0) scale(1.04);
  }
  to {
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes tile-palette-rejected {
  0%, 100% { transform: translate3d(0, 0, 0); }
  20% { transform: translate3d(-4px, 0, 0); }
  40% { transform: translate3d(4px, 0, 0); }
  60% { transform: translate3d(-3px, 0, 0); }
  80% { transform: translate3d(3px, 0, 0); }
}

@keyframes tile-face-rejected {
  0%, 100% {
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12), inset 0 -2px 0 rgba(0, 0, 0, 0.05);
  }
  15%, 45%, 75% {
    border-color: #c0392b;
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.45);
  }
  30%, 60% {
    border-color: #c0392b;
    box-shadow: 0 0 0 5px rgba(192, 57, 43, 0.2);
  }
}

@keyframes tile-face-ripple {
  0% {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 0 rgba(var(--color-primary-rgb), 0.45);
  }
  45% {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 6px rgba(var(--color-primary-rgb), 0.16);
  }
  100% {
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12), inset 0 -2px 0 rgba(0, 0, 0, 0.05);
  }
}

@keyframes tile-hand-enter {
  from {
    transform: translate3d(0, 8px, 0) scale(0.72);
    opacity: 0;
  }
  to {
    transform: translate3d(0, 0, 0) scale(1);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .palette-tile.is-flash-success,
  .palette-tile.is-flash-rejected,
  .hand-tile.is-just-added,
  .hand-tile.is-removing,
  .hand-tile.is-shifting,
  .hand-tile.is-dragging-absolute,
  .calc-controls button.is-flash-success,
  .calc-controls button.is-flash-rejected,
  .calc-reset.is-flash-success,
  .calc-reset.is-flash-rejected,
  .calc-reset.is-share-ready {
    animation: none;
  }

  .calc-reset.is-share-ready,
  .calc-reset.is-share-ready:hover {
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.45);
  }

  .opt-check.is-flash-success {
    animation: none;
    background: rgba(var(--color-primary-rgb), 0.12);
  }

  .palette-tile.is-flash-success .tile-face,
  .hand-tile.is-just-added .tile-face {
    animation: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(var(--color-primary-rgb), 0.35);
  }

  .palette-tile.is-flash-rejected .tile-face,
  .hand-tile.is-removing .tile-face {
    animation: none;
    border-color: #c0392b;
    box-shadow: 0 0 0 2px rgba(192, 57, 43, 0.45);
  }

  .calc-controls button.is-flash-success,
  .calc-reset.is-flash-success {
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.55);
    border-color: var(--color-primary);
  }

  .calc-controls button.is-flash-rejected,
  .calc-reset.is-flash-rejected {
    border-color: #c0392b;
  }
}

/* Options */
.calc-options { display: block; }

.calc-options-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.calc-options-table tr + tr td {
  padding-top: 0.75rem;
}

.calc-options-table td {
  padding: 0.25rem 0.85rem 0.25rem 0;
  vertical-align: middle;
}

.calc-options-table td:last-child {
  padding-right: 0;
}

.calc-options-table td:not(:last-child) {
  padding-right: 0.85rem;
}

.calc-options-table .opt-check {
  align-items: center;
  margin: 0;
  padding: 0.15rem 0;
}

.calc-options-table .opt-check input {
  margin-top: 0;
}

.calc-options-table .opt-select {
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.calc-options-table .opt-select select {
  flex: 1;
  min-width: 0;
}

.calc-options-table tr.calc-options-winds .opt-select--inline {
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  font-size: 0.82rem;
}

.calc-options-table tr.calc-options-winds .opt-select--inline select {
  flex: none;
  width: 4.5rem;
  min-width: 4.5rem;
  font-size: 0.85rem;
  padding: 0.42rem 0.35rem;
}

.calc-options-table,
.calc-options-table tbody {
  display: block;
  width: 100%;
}

.calc-options-table tr {
  display: grid;
  gap: 0.55rem 0.85rem;
}

.calc-options-table tr:first-child,
.calc-options-table tr.calc-options-winds {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.calc-options-table tr + tr {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
}

.calc-options-table tr + tr td {
  padding-top: 0;
}

.calc-options-table td {
  display: block;
  padding: 0;
}

@media (max-width: 479px) {
  .calc-options-table tr.calc-options-winds .opt-select--inline {
    font-size: 0.76rem;
    gap: 0.3rem;
  }

  .calc-options-table tr.calc-options-winds .opt-select--inline select {
    width: 4.25rem;
    min-width: 4.25rem;
    font-size: 0.78rem;
    padding: 0.38rem 0.25rem;
  }
}

.opt-check {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--color-text);
  cursor: pointer;
  border-radius: 6px;
  padding: 0.2rem 0.35rem;
  margin: -0.2rem -0.35rem;
  transition: background 0.15s;
}

.opt-check input {
  margin-top: 0.2rem;
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.opt-check .opt-cn { color: var(--color-text-muted); }

.opt-select {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
}

.opt-select select {
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  background: var(--color-background);
  color: var(--color-text);
}

/* Result */
.calc-result { margin-top: 0.5rem; }

.result-note {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  margin: 0;
}

.result-list {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.result-item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.7rem;
  background: var(--color-background);
  border-radius: 8px;
  font-size: 0.92rem;
}

.result-cn { color: var(--color-text-muted); }
.result-faan { font-weight: 700; color: var(--color-primary); white-space: nowrap; }

.result-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0.9rem;
  background: var(--color-primary);
  color: #fff;
  border-radius: 10px;
  font-size: 1.05rem;
}

.result-total strong { font-size: 1.15rem; }

.result-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.spicy-toggle {
  display: inline-flex;
  flex-shrink: 0;
  border: 1px solid rgba(var(--color-primary-rgb), 0.25);
  border-radius: 8px;
  overflow: hidden;
  background: var(--color-background);
}

.spicy-toggle-btn {
  border: 0;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.45rem 0.65rem;
  cursor: pointer;
  white-space: nowrap;
}

.spicy-toggle-btn.is-active {
  background: var(--color-primary);
  color: #fff;
}

.spicy-toggle-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

.result-footer .result-payout {
  margin: 0;
  flex: 1;
}

.result-payout {
  margin: 0.75rem 0 0;
  font-size: 0.95rem;
  color: var(--color-text);
  text-align: right;
}

.result-payout strong { color: var(--color-primary); }
.result-below { color: var(--color-text-muted); font-style: italic; }

.calc-disclaimer {
  margin-top: 2.2rem;
  text-align: center;
  font-size: 0.88rem;
  color: var(--color-text-muted);
  font-style: italic;
}

/* ---- Back-to-home / page footer link ---- */
.points-backlink {
  text-align: center;
  padding: 0 0 2.5rem;
  background: var(--color-surface);
}
.points-backlink .btn { justify-content: center; }

.points-cta {
  text-align: center;
  margin-top: 2rem;
}
.points-cta .btn { justify-content: center; }

/* ---- Attribution ---- */
.tile-credit {
  text-align: center;
  font-size: 0.82rem;
  color: var(--color-text-muted);
  margin-top: 1.5rem;
}

@media (max-width: 768px) {
  .calc-card-head {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
  }

  .calc-card-head h3 {
    flex: 1;
    min-width: 0;
  }

  .calc-card-head .calc-reset,
  .calc-card-actions {
    flex-shrink: 0;
  }

  .calc-card-actions {
    flex-wrap: nowrap;
    justify-content: flex-end;
  }

  .calc .palette-row {
    --calc-tile-gap: 0.2rem;
    gap: var(--calc-tile-gap);
  }

  .calc .hand-tiles {
    --calc-tile-gap: 0.25rem;
    gap: var(--calc-tile-gap);
  }

  .calc .palette-tile {
    width: calc((100% - 8 * var(--calc-tile-gap)) / 9);
    flex: 0 0 calc((100% - 8 * var(--calc-tile-gap)) / 9);
    max-width: calc((100% - 8 * var(--calc-tile-gap)) / 9);
  }

  .calc .hand-tile {
    width: calc((100% - 6 * var(--calc-tile-gap)) / 7);
    flex: 0 0 calc((100% - 6 * var(--calc-tile-gap)) / 7);
    max-width: calc((100% - 6 * var(--calc-tile-gap)) / 7);
  }

  .calc .palette-tile .tile-face,
  .calc .hand-tile .tile-face {
    border-radius: 8px;
    padding: 8% 6% 4% 6%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1), inset 0 -1px 0 rgba(0, 0, 0, 0.04);
  }

  .faan-table {
    font-size: 0.84rem;
    table-layout: fixed;
  }

  .faan-table:not(.payout-faan-table):has(th:nth-child(3)) th:nth-child(1),
  .faan-table:not(.payout-faan-table):has(th:nth-child(3)) td:nth-child(1) { width: 32%; }

  .faan-table:not(.payout-faan-table):has(th:nth-child(3)) th:nth-child(2),
  .faan-table:not(.payout-faan-table):has(th:nth-child(3)) td:nth-child(2) { width: 16%; }

  .faan-table:not(.payout-faan-table):has(th:nth-child(3)) th:nth-child(3),
  .faan-table:not(.payout-faan-table):has(th:nth-child(3)) td:nth-child(3) { width: 52%; }

  .faan-table th,
  .faan-table td {
    padding: 0.55rem 0.5rem;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .faan-table th {
    white-space: normal;
  }

  .faan-table td:first-child,
  .faan-table th:first-child {
    white-space: normal;
  }

  .faan-value {
    white-space: normal;
  }

  .faan-desc {
    font-size: 0.85rem;
  }

  .payout-faan-table {
    display: block;
  }

  .payout-faan-table colgroup {
    display: none;
  }

  .payout-faan-table thead,
  .payout-faan-table tbody {
    display: block;
  }

  .payout-faan-table tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    column-gap: 0;
  }

  .payout-faan-table th,
  .payout-faan-table td {
    display: block;
    min-width: 0;
    width: auto;
  }

  .payout-faan-table tbody {
    width: 100%;
  }
}

@media (max-width: 600px) {
  .calc-card-head .calc-reset,
  .calc-left .calc-card-actions .calc-reset,
  .calc-right .calc-card-head .calc-reset {
    font-size: 0.72rem;
    padding: 0.38rem 0.6rem;
  }

  .calc-controls { gap: 0.3rem; }
  .calc-controls button {
    font-size: clamp(0.68rem, 2.6vw, 0.72rem);
    padding: 0.35rem 0.12rem;
    white-space: nowrap;
  }
  .tile-face {
    padding: 10% 8% 5% 8%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1), inset 0 -1px 0 rgba(0, 0, 0, 0.04);
  }
  .tile-face img { object-position: center 55%; }
  .points-section { padding: 2.25rem 0; }
  .opt-check {
    font-size: 0.7rem;
  }
}
