  :root {
    --sand: #c8a96e;
    --sand-light: #e8d5a3;
    --sand-dark: #8b6914;
    --spice: #d4470a;
    --spice-glow: #ff6b1a;
    --night: #0a0806;
    --deep: #12100c;
    --stone: #1e1a14;
    --stone-mid: #2a2318;
    --stone-light: #3d3526;
    --parchment: #f5ead0;
    --leto-red: #962a2a;
    --leto-light: #c05b5b;
    --baron-green: #1a5c1a;
    --baron-light: #3d9e3d;
    --emperor-gold: #c9a227;
    --emperor-glow: #f5d060;
    --sq: #c8a96e;
    --ci: #5b9dc0;
    --tr: #7dbe6a;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }

  html {
    /* Fluid base font: 14px at 900px wide, 18px at 1400px wide, clamped */
    font-size: clamp(14px, 1.2vw + 3px, 20px);
  }

  body {
    background: var(--night);
    color: var(--parchment);
    font-family: 'EB Garamond', serif;
    min-height: 100vh;
    overflow-x: hidden;
  }

  /* Sand texture overlay */
  body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
  }

  #bg-layer {
    position: fixed;
    inset: 0;
    z-index: -1;
    background-size: cover;
    background-position: center;
    opacity: 0.35;
    pointer-events: none;
  }

  #app { position: relative; z-index: 1; padding: 3px 10vw; padding-bottom: 120px; }

  /* HEADER */
  header {
    text-align: center;
    padding: 6px 0 6px;
    border-bottom: 1px solid rgba(200,169,110,0.3);
    margin-bottom: 1px;
    min-height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
  header h1 {
    font-family: 'Cinzel Decorative', serif;
    font-size: 1.6rem;
    color: var(--sand);
    letter-spacing: 0.15em;
    text-shadow: 0 0 20px rgba(200,169,110,0.3), 0 2px 4px rgba(0,0,0,0.8);
  }
  header .subtitle {
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
    letter-spacing: 0.4em;
    color: rgba(200,169,110,0.5);
    margin-top: 4px;
  }

  /* SCORE PANEL */
  #score-panel {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 8px;
    margin-bottom: 4px;
    align-items: stretch;
    min-height: 90px;
  }

  .player-score {
    background: var(--stone);
    border: 1px solid rgba(200,169,110,0.2);
    border-radius: 6px;
    min-height: 110px;
    padding: 6px 8px 4px;
    position: relative;
    overflow: visible;
    display: flex;
    flex-direction: column;
  }
  .player-score::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
  }
  .player-score.leto::before { background: linear-gradient(90deg, var(--leto-red), var(--leto-light)); }
  .player-score.baron::before { background: linear-gradient(90deg, var(--baron-green), var(--baron-light)); }
  .player-score.active-player { box-shadow: 0 0 0 1px rgba(200,169,110,0.5), 0 0 20px rgba(200,169,110,0.1); }

  .player-name {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .leto .player-name { color: var(--leto-light); }
  .baron .player-name { color: var(--baron-light); }

  .player-score.leto { align-items: flex-end; text-align: right; }
  .player-score.leto .player-name { width: 100%; justify-content: flex-end; }
  .player-score.leto .score-row { justify-content: flex-end; }
  .player-score.leto .resource-row { justify-content: flex-end; }
  .player-score.leto .blocked-indicator { text-align: right; }
  .player-sigil {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.7;
    pointer-events: none;
  }
  .player-score.leto .player-sigil { left: 10px; transform: translateY(-50%); }
  .player-score.baron .player-sigil { right: 10px; transform: translateY(-50%); }

  .score-row {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
    min-height: 28px;
  }
  .score-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 0.95rem;
  }
  .score-chip .sym { font-size: 1rem; }
  .score-chip .val { font-weight: 500; min-width: 16px; }
  .score-chip.sq .sym { color: var(--sq); }
  .score-chip.ci .sym { color: var(--ci); }
  .score-chip.tr .sym { color: var(--tr); }
  .score-chip.total {
    background: rgba(200,169,110,0.1);
    border: 1px solid rgba(200,169,110,0.3);
    color: var(--sand);
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
  }

  .resource-row {
    display: flex;
    gap: 8px;
    font-size: 1rem;
    color: rgba(245,234,208,0.85);
    flex-wrap: wrap;
    min-height: 24px;
  }
  .resource-row span { display: flex; align-items: center; gap: 3px; }

  .blocked-indicator {
    font-size: 1rem;
    color: #e74c3c;
    margin-top: 4px;
    font-style: italic;
  }

  .win-chip {
    display: inline-block;
    background: rgba(200,169,110,0.15);
    border: 1px solid var(--sand);
    border-radius: 3px;
    padding: 1px 6px;
    font-family: 'Cinzel', serif;
    font-size: 0.58rem;
    color: var(--sand);
    margin-left: auto;
  }
  .leto .win-chip {
    margin-left: 0;
    margin-right: auto;
  }

  /* EMPEROR */
  .emperor-panel {
    background: var(--stone);
    border: 1px solid rgba(201,162,39,0.3);
    border-radius: 6px;
    padding: 8px 12px 6px;
    text-align: center;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    box-sizing: border-box;
  }
  .emperor-panel::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--emperor-gold), transparent);
  }
  .emperor-title {
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
    letter-spacing: 0.15em;
    color: rgba(201,162,39,0.6);
    margin-bottom: 8px;
  }
  .emperor-pts-row {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 4px;
  }
  .emperor-pts {
    font-family: 'Cinzel Decorative', serif;
    font-size: 1.3rem;
    color: var(--emperor-gold);
    text-shadow: 0 0 20px rgba(201,162,39,0.5);
    line-height: 1;
  }
  .emperor-label {
    font-size: 0.75rem;
    color: rgba(201,162,39,0.5);
  }

  /* BLOCKED SYMBOLS */
  #blocked-panel {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 8px;
  }
  .blocked-sym {
    background: rgba(231,76,60,0.15);
    border: 1px solid rgba(231,76,60,0.4);
    border-radius: 4px;
    padding: 2px 10px;
    font-size: 0.95rem;
    color: #e74c3c;
    display: flex; align-items: center; gap: 4px;
  }

  /* DISPLAY */
  #display-section {
    margin-bottom: 3px;
  }
  #mobile-deck-info { display: none; }
  .section-label {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    letter-spacing: 0.2em;
    color: rgba(200,169,110,0.5);
    margin-bottom: 1px;
    text-transform: uppercase;
  }
  #ai-tableau-label.baron-label { color: var(--baron-light); opacity: 0.75; }
  #ai-tableau-label.leto-label  { color: var(--leto-light);  opacity: 0.75; }
  #player-section .tableau-area .section-label.baron-label { color: var(--baron-light); opacity: 0.75; }
  #player-section .tableau-area .section-label.leto-label  { color: var(--leto-light);  opacity: 0.75; }

  #display-cards {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 240px));
    gap: 10px;
    max-width: 100%;
    justify-content: center;
    align-items: center;
  }

  /* CARD */
  .display-slot-empty {
    aspect-ratio: 3/4;
    width: 100%;
  }

  .card {
    background: var(--stone);
    border: 1px solid rgba(200,169,110,0.25);
    border-radius: 8px;
    padding: 4px;
    cursor: default;
    transition: all 0.2s;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-size: 0.8em;
  }
  .card-img-wrap {
    position: relative;
  }
  .card-img {
    width: 100%;
    border-radius: 5px;
    display: block;
    object-fit: cover;
  }
  /* Show complete card — no cropping */
  .card-img-wrap {
    position: relative;
  }
  .card-img { height: auto !important; object-fit: contain !important; }
  .card-tucked {
    display: block;
    text-align: center;
    margin-top: 4px;
    color: rgba(200,169,110,0.8);
    font-family: 'EB Garamond', serif;
    font-size: 0.6rem;
    font-style: italic;
    letter-spacing: 0.03em;
    pointer-events: none;
    line-height: 1.2;
  }
  .card.buyable {
    cursor: pointer;
    border-color: rgba(200,169,110,0.5);
  }
  .card.blocked { opacity: 0.4; }

  .card.buyable:hover {
    background: var(--stone-mid);
    border-color: var(--sand);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(200,169,110,0.2);
  }
  .card.escalation-card {
    background: var(--stone);
    border-color: rgba(201,162,39,0.4);
  }
  .card.escalation-card .card-name {
    color: var(--emperor-gold);
  }

  .card-cost {
    display: block;
    text-align: center;
    background: var(--stone-light);
    border: 1px solid rgba(200,169,110,0.4);
    border-radius: 0 0 6px 6px;
    padding: 3px 8px;
    font-size: 0.85rem;
    font-family: 'Cinzel', serif;
    color: var(--sand);
    white-space: nowrap;
    margin-top: 4px;
  }

  .card-display-title {
    font-family: 'Cinzel', serif;
    font-size: 0.78rem;
    font-weight: 600;
    color: rgba(245,234,208,0.9);
    text-align: center;
    letter-spacing: 0.04em;
    line-height: 1.2;
    padding: 4px 4px 3px;
    background: rgba(0,0,0,0.25);
    border-radius: 5px 5px 0 0;
    margin-bottom: 3px;
  }
  .card-title-small {
    font-size: 0.58rem;
    padding: 2px 3px 2px;
    letter-spacing: 0.02em;
  }
  .card-cost.free { color: #7dbe6a; border-color: rgba(125,190,106,0.4); }
  .card-cost.costly { color: #e74c3c; border-color: rgba(231,76,60,0.4); }

  /* ESCALATION CARD FLASH ANIMATION */
  @keyframes esc-flash {
    0%   { box-shadow: 0 0 0 0 rgba(231,76,60,0);    border-color: rgba(200,169,110,0.4); }
    20%  { box-shadow: 0 0 28px 10px rgba(231,76,60,0.9); border-color: rgba(231,76,60,1); }
    45%  { box-shadow: 0 0 6px 2px rgba(231,76,60,0.25); border-color: rgba(231,76,60,0.4); }
    70%  { box-shadow: 0 0 28px 10px rgba(231,76,60,0.9); border-color: rgba(231,76,60,1); }
    100% { box-shadow: 0 0 0 0 rgba(231,76,60,0);    border-color: rgba(200,169,110,0.4); }
  }
  .card-esc-flash {
    animation: esc-flash 2s ease-in-out forwards;
  }

  /* CARD USE PULSE ANIMATION */
  @keyframes use-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(91,157,192,0.0); }
    40%  { box-shadow: 0 0 20px 8px rgba(91,157,192,0.7); }
    100% { box-shadow: 0 0 0 0 rgba(91,157,192,0.0); }
  }
  .card-use-pulse {
    animation: use-pulse 0.3s ease-out forwards;
  }

  /* DECK PILE */
  .deck-pile {
    background: var(--deep);
    border: 1px solid rgba(200,169,110,0.3);
    border-radius: 8px;
    padding: 0;
    cursor: default;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    overflow: hidden;
    aspect-ratio: 3/4;
  }
  .deck-pile-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-left: 10px;
  }
  #display-cards .deck-pile-wrapper { width: 100%; }
  #display-cards .deck-pile { width: 100%; }
  .deck-pile-count,
  .deck-pile-discard {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    letter-spacing: 0.2em;
    color: rgba(200,169,110,0.5);
    text-transform: uppercase;
    text-align: center;
    line-height: 1;
  }
  .deck-pile-count { margin-bottom: 4px; }
  .deck-pile-discard { margin-top: 4px; }
  .deck-pile-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 7px;
    display: block;
  }
  .deck-pile-label {
    display: none;
  }
  .card-solari-on {
    position: absolute;
    top: 51%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3.825rem;
    line-height: 1;
    pointer-events: none;
    z-index: 2;
  }
  .tableau-card .card-solari-on {
    font-size: 1.513rem;
    top: 63%;
    transform: translate(-50%, -50%);
  }
  .card-name {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 600;
    color: rgba(245,234,208,0.9);
    margin-bottom: 6px;
    margin-top: 6px;
    letter-spacing: 0.05em;
    line-height: 1.2;
  }

  .card-scores {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 6px;
    flex: 1;
  }

  .score-line {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.88rem;
  }
  .score-line .sym-icon { font-size: 1rem; }
  .score-line.play-score { color: var(--parchment); }
  .score-line.use-score { color: rgba(245,234,208,0.85); font-size: 0.82rem; }
  .score-line.use-label {
    font-size: 0.82rem;
    color: rgba(245,234,208,0.9);
    font-style: italic;
    margin-top: 2px;
  }
  .score-line .player-tag {
    font-size: 0.68rem;
    padding: 1px 4px;
    border-radius: 3px;
    font-family: 'Cinzel', serif;
  }
  .score-line .player-tag.leto { background: rgba(150,42,42,0.3); color: var(--leto-light); }
  .score-line .player-tag.baron { background: rgba(26,92,26,0.3); color: var(--baron-light); }

  .card-power {
    font-size: 0.95rem;
    color: rgba(200,169,110,0.9);
    font-style: italic;
    border-top: 1px solid rgba(200,169,110,0.1);
    padding-top: 4px;
    margin-top: auto;
    line-height: 1.3;
  }

  .discard-cost-badge {
    font-size: 0.82rem;
    color: #e74c3c;
    background: rgba(231,76,60,0.1);
    border-radius: 3px;
    padding: 1px 4px;
    display: inline-block;
    margin-bottom: 3px;
  }

  .escalation-pts {
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    color: var(--emperor-gold);
    text-align: center;
    margin: 4px 0;
  }
  .escalation-block {
    font-size: 0.95rem;
    text-align: center;
    color: #e74c3c;
  }

  /* HAND & TABLEAU */
  #player-section {
    display: grid;
    grid-template-columns: fit-content(calc(4 * 120px + 3 * 8px + 20px)) 1fr;
    gap: 8px;
    margin-bottom: 8px;
  }

  .hand-area, .tableau-area {
    background: var(--stone);
    border: 1px solid rgba(200,169,110,0.15);
    border-radius: 8px;
    padding: 1px 10px 3px;
  }

  .hand-cards {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 8px;
    min-height: 60px;
  }

  .tableau-cards {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
    min-height: 60px;
  }

  .hand-card {
    background: var(--stone-mid);
    border: 1px solid rgba(200,169,110,0.3);
    border-radius: 6px;
    padding: 8px;
    width: 120px;
    cursor: default;
    transition: all 0.2s;
    position: relative;
  }
  .hand-card.playable {
    cursor: pointer;
    border-color: rgba(125,190,106,0.5);
  }
  .hand-card.playable:hover {
    border-color: #7dbe6a;
    background: var(--stone-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(125,190,106,0.2);
  }
  .hand-card.selected {
    border-color: #7dbe6a;
    background: var(--stone-light);
    box-shadow: 0 0 0 2px rgba(125,190,106,0.3);
  }

  .tableau-card {
    background: var(--stone-mid);
    border: 1px solid rgba(200,169,110,0.2);
    border-radius: 6px;
    padding: 8px;
    width: 120px;
    position: relative;
    transition: all 0.2s;
  }
  .tableau-card.useable {
    cursor: pointer;
    border-color: rgba(91,157,192,0.5);
  }
  .tableau-card.useable:hover {
    border-color: var(--leto-light);
    background: var(--stone-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(91,157,192,0.2);
  }
  .protected-badge {
    position: absolute;
    top: 2px; right: 2px;
    font-size: 0.95rem;
    color: var(--sand);
    background: rgba(200,169,110,0.15);
    border-radius: 3px;
    padding: 1px 3px;
  }
  .solari-on-card {
    position: absolute;
    bottom: 2px; right: 2px;
    font-size: 0.82rem;
    color: var(--sand);
  }


  /* OPPONENT HAND (face-down) */
  .opp-hand-card {
    background: var(--stone-mid);
    border: 1px solid rgba(200,169,110,0.2);
    border-radius: 6px;
    width: 120px;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
  }
  .opp-hand-card .card-img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 5px;
    object-fit: contain;
  }
  .opp-hand-placeholder {
    width: 100%;
    aspect-ratio: 3/4;
    background: var(--stone);
    border-radius: 5px;
  }

  /* AI TABLEAU */
  #ai-section {
    display: grid;
    grid-template-columns: fit-content(calc(4 * 120px + 3 * 8px + 20px)) 1fr;
    gap: 8px;
    margin-bottom: 8px;
  }
  #ai-tableau-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  /* ACTION LOG */
  #log-panel {
    background: var(--stone);
    border-top: 1px solid rgba(200,169,110,0.2);
    padding: 8px 16px;
    height: 390px; /* ~4 log entries visible + label row */
    overflow-y: scroll;
    margin-top: 4px;
  }
  .log-label {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(200,169,110,0.4);
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(200,169,110,0.1);
  }
  .log-entry {
    font-size: 0.88rem;
    color: rgba(245,234,208,0.9);
    padding: 2px 0;
    border-bottom: 1px solid rgba(200,169,110,0.05);
    line-height: 1.4;
  }
  .log-entry.leto { color: var(--leto-light); }
  .log-entry.baron { color: var(--baron-light); }
  .log-entry.system { color: var(--emperor-gold); font-style: italic; }
  .log-entry.escalation { color: #e74c3c; font-style: italic; }

  /* ACTION BUTTONS */
  #action-bar {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
  }

  .btn {
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
    letter-spacing: 0.1em;
    padding: 8px 20px;
    border: 1px solid;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
    text-transform: uppercase;
  }
  .btn:disabled { opacity: 0.3; cursor: not-allowed; }
  .btn-sm {
    font-size: 0.65rem;
    padding: 4px 12px;
    letter-spacing: 0.08em;
  }

  .btn-primary {
    color: var(--sand);
    border-color: var(--sand);
  }
  .btn-primary:hover:not(:disabled) {
    background: rgba(200,169,110,0.15);
    box-shadow: 0 0 15px rgba(200,169,110,0.2);
  }

  .btn-danger {
    color: #e74c3c;
    border-color: rgba(231,76,60,0.5);
  }
  .btn-danger:hover:not(:disabled) {
    background: rgba(231,76,60,0.1);
  }

  .btn-success {
    color: rgba(200,169,110,0.8);
    border-color: rgba(125,190,106,0.5);
  }
  .btn-success:hover:not(:disabled) {
    background: rgba(125,190,106,0.1);
  }

  /* STATUS */
  .status-blocked { color: var(--spice-glow); }

  #status-bar {
    text-align: center;
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    color: var(--sand);
    min-height: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0;
    letter-spacing: 0.05em;
  }

  /* MODAL */
  .modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.85);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
  }
  .modal {
    background: var(--stone);
    border: 1px solid rgba(200,169,110,0.4);
    border-radius: 12px;
    padding: clamp(16px, 4vw, 40px);
    max-width: min(560px, 94vw);
    width: 94%;
    text-align: center;
    position: relative;
    box-shadow: 0 0 60px rgba(200,169,110,0.1);
    max-height: 92vh;
    overflow-y: auto;
    font-family: 'EB Garamond', serif;
  }
  .modal::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: 12px 12px 0 0;
    background: linear-gradient(90deg, transparent, var(--emperor-gold), transparent);
  }
  .modal h2 {
    font-family: 'Cinzel Decorative', serif;
    font-size: 1.4rem;
    color: var(--sand);
    margin-bottom: 8px;
  }
  .modal .winner-name {
    font-family: 'Cinzel', serif;
    font-size: clamp(1.2rem, 4vw, 2rem);
    margin: 12px 0;
    text-shadow: 0 0 20px currentColor;
  }
  .modal .winner-name.leto { color: var(--leto-light); }
  .modal .winner-name.baron { color: var(--baron-light); }
  .modal .winner-name.emperor { color: var(--emperor-gold); }
  .modal .final-scores {
    background: var(--deep);
    border-radius: 8px;
    padding: clamp(10px, 2.5vw, 20px);
    margin: 12px 0;
    text-align: left;
    font-size: clamp(0.8rem, 1.8vw, 1rem);
    line-height: 1.9;
  }
  .modal .final-scores .label {
    font-family: 'Cinzel', serif;
    font-size: clamp(0.8rem, 1.6vw, 1rem);
    color: rgba(200,169,110,0.5);
    letter-spacing: 0.1em;
  }

  /* PENDING ACTION indicator */
  #pending-action {
    text-align: center;
    font-size: 0.95rem;
    color: rgba(200,169,110,0.7);
    font-style: italic;
    min-height: 20px;
  }
  /* ACTION ROW: pending message + button on same line when space allows */
  #action-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 1px;
    min-height: 28px;
  }
  #pending-action {
    margin-bottom: 0;
    flex-shrink: 1;
    min-width: 0;
    text-align: center;
  }
  #action-bar {
    margin-bottom: 0;
    flex-shrink: 0;
  }


  /* DECK INFO */
  .deck-info {
    text-align: center;
    font-size: 1rem;
    color: rgba(200,169,110,0.4);
    margin-bottom: 8px;
    font-family: 'Cinzel', serif;
    letter-spacing: 0.05em;
  }

  .turn-indicator {
    display: inline-block;
    background: rgba(200,169,110,0.1);
    border: 1px solid rgba(200,169,110,0.3);
    border-radius: 4px;
    padding: 2px 10px;
    font-size: 0.95rem;
    font-family: 'Cinzel', serif;
    letter-spacing: 0.1em;
    margin-left: 8px;
    vertical-align: middle;
  }
  .turn-indicator.your-turn { color: #7dbe6a; border-color: rgba(125,190,106,0.4); }
  .turn-indicator.ai-turn { color: var(--sand); border-color: rgba(200,169,110,0.3); }


  /* Prevent long-press text selection on interactive elements */
  .btn, .card, .hand-card, .tableau-card, .faction-btn {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }


  ::-webkit-scrollbar-track { background: var(--deep); }
  ::-webkit-scrollbar-thumb { background: rgba(200,169,110,0.3); border-radius: 2px; }

  /* CATEGORY WIN indicators */
  .cat-win { color: #7dbe6a; }
  .cat-lose { color: rgba(245,234,208,0.4); }


  /* Card hover popup */
  #card-popup {
    display: none;
    position: fixed;
    z-index: 999;
    pointer-events: none;
    filter: drop-shadow(0 8px 32px rgba(0,0,0,0.8));
    opacity: 0;
    transition: opacity 0.12s ease;
  }
  #card-popup.visible {
    display: block;
    opacity: 1;
  }
  #card-popup img {
    width: 380px;
    border-radius: 10px;
    display: block;
  }

  /* Faction selection modal */
  #faction-modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.92);
    display: flex; align-items: center; justify-content: center;
    z-index: 200;
    backdrop-filter: blur(6px);
  }
  #faction-modal .modal {
    max-width: 560px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 320px;
    padding: 20px 10px 10px;
  }
  #faction-modal h2 {
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    color: var(--sand);
    margin-bottom: 6px;
    letter-spacing: 0.15em;
    text-shadow: 0 0 20px rgba(200,169,110,0.3), 0 2px 4px rgba(0,0,0,0.8);
    font-weight: 400;
  }
  #faction-modal .faction-subtitle {
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
    letter-spacing: 0.4em;
    color: rgba(200,169,110,0.5);
    font-style: normal;
    margin-bottom: 24px;
  }

  .difficulty-select {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
  }
  .difficulty-label {
    font-family: 'Cinzel', serif;
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    color: rgba(200,169,110,0.7);
    text-transform: uppercase;
  }
  .diff-btns {
    display: flex;
    gap: 8px;
  }
  .diff-btn {
    font-family: 'Cinzel', serif;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    padding: 6px 14px;
    border: 1px solid rgba(200,169,110,0.4);
    border-radius: 20px;
    background: transparent;
    color: rgba(200,169,110,0.6);
    cursor: pointer;
    transition: all 0.18s;
  }
  .diff-btn:hover {
    border-color: var(--sand);
    color: var(--sand);
    background: rgba(200,169,110,0.08);
  }
  .diff-btn.active {
    border-color: var(--sand);
    color: var(--sand);
    background: rgba(200,169,110,0.15);
    font-weight: 600;
  }
  .faction-choices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: auto;
    margin-bottom: auto;
  }
  .faction-btn {
    border: 2px solid;
    border-radius: 10px;
    padding: 20px 16px;
    cursor: pointer;
    background: transparent;
    transition: all 0.2s;
    text-align: center;
  }
  .faction-btn:hover { transform: translateY(-3px); }
  .faction-btn.leto {
    border-color: var(--leto-red);
    color: var(--leto-light);
  }
  .faction-btn.leto:hover {
    background: rgba(150,42,42,0.15);
    box-shadow: 0 0 30px rgba(150,42,42,0.3);
  }
  .faction-btn.baron {
    border-color: var(--baron-green);
    color: var(--baron-light);
  }
  .faction-btn.baron:hover {
    background: rgba(26,92,26,0.15);
    box-shadow: 0 0 30px rgba(26,92,26,0.3);
  }
  .faction-btn .faction-name {
    font-family: 'Cinzel', serif;
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
    display: block;
  }
  .faction-btn .faction-house {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    letter-spacing: 0.15em;
    opacity: 0.7;
    display: block;
    margin-bottom: 12px;
  }
  .faction-btn .faction-desc {
    font-size: 0.82rem;
    line-height: 1.5;
    opacity: 0.8;
    font-family: 'Cinzel', serif;
  }

  .name-short { display: none; }
  #phone-btn-row { height: 0; overflow: visible; padding: 0; margin: 0; }
  .name-solari { display: none; }


  .you-tag {
    font-size: 0.82rem;
    background: rgba(125,190,106,0.2);
    border: 1px solid rgba(125,190,106,0.5);
    color: rgba(200,169,110,0.8);
    border-radius: 3px;
    padding: 1px 5px;
    font-family: 'Cinzel', serif;
    letter-spacing: 0.1em;
    vertical-align: middle;
  }
  .ai-tag {
    font-size: 0.82rem;
    background: rgba(200,169,110,0.1);
    border: 1px solid rgba(200,169,110,0.3);
    color: rgba(200,169,110,0.6);
    border-radius: 3px;
    padding: 1px 5px;
    font-family: 'Cinzel', serif;
    letter-spacing: 0.1em;
    vertical-align: middle;
  }


  /* Discard selection modal */
  #discard-modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.88);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 150;
    backdrop-filter: blur(4px);
  }
  #discard-modal.open { display: flex; }
  #discard-modal .modal { max-width: 620px; width: 95%; }
  #discard-modal h2 {
    font-family: 'Cinzel', serif;
    font-size: clamp(0.82rem, 2.5vw, 1.1rem);
    color: #e74c3c;
    margin-bottom: 6px;
    letter-spacing: 0.1em;
  }
  .discard-subtitle {
    font-family: 'Cinzel', serif;
    font-size: clamp(0.78rem, 1.5vw, 0.9rem);
    color: rgba(245,234,208,0.6);
    margin-bottom: 16px;
    font-style: italic;
  }
  #discard-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
  }
  .discard-choice {
    cursor: pointer;
    border: 2px solid rgba(231,76,60,0.4);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.15s;
    width: 120px;
  }
  .discard-choice:hover {
    border-color: #e74c3c;
    transform: translateY(-3px);
    box-shadow: 0 4px 20px rgba(231,76,60,0.3);
  }
  .discard-choice img { width: 100%; display: block; }


  /* Kanly target selection modal */
  #intrigue-modal {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.85);
    align-items: center;
    justify-content: center;
    z-index: 150;
    backdrop-filter: blur(4px);
  }
  #intrigue-modal.open { display: flex; }
  #intrigue-modal .modal { max-width: 680px; width: 95%; }
  #intrigue-modal h2 {
    font-family: 'Cinzel', serif;
    font-size: clamp(0.82rem, 2.5vw, 1.1rem);
    color: var(--ci);
    margin-bottom: 6px;
    letter-spacing: 0.1em;
  }
  #intrigue-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 12px;
  }
  #intrigue-choices .intrigue-group-label {
    width: 100%;
    font-family: 'Cinzel', serif;
    font-size: 0.62rem;
    letter-spacing: 0.1em;
    color: rgba(200,169,110,0.5);
    text-transform: uppercase;
    margin: 6px 0 2px;
  }
  #intrigue-choices .intrigue-choice {
    cursor: pointer;
    border: 1px solid rgba(91,157,192,0.35);
    border-radius: 6px;
    overflow: hidden;
    transition: border-color 0.2s, transform 0.15s;
    width: clamp(80px, 14vw, 110px);
  }
  #intrigue-choices .intrigue-choice:hover {
    border-color: var(--ci);
    transform: translateY(-3px);
    box-shadow: 0 0 16px rgba(91,157,192,0.35);
  }
  #intrigue-choices .intrigue-choice img { width: 100%; display: block; }
  #intrigue-choices .intrigue-none {
    color: rgba(245,234,208,0.4);
    font-style: italic;
    font-size: clamp(0.78rem, 1.5vw, 0.9rem);
    padding: 12px;
    font-family: 'Cinzel', serif;
  }

  #steal-solari-modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.88);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 150;
    backdrop-filter: blur(4px);
  }
  #steal-solari-modal.open { display: flex; }
  #steal-solari-modal .modal { max-width: 720px; width: 95%; }
  #steal-solari-choices {
    display: flex;
    flex-wrap: wrap;
    flex-direction: row;
    gap: 10px;
    justify-content: center;
    margin-top: 12px;
  }
  #steal-solari-modal h2 {
    font-family: 'Cinzel', serif;
    font-size: clamp(0.82rem, 2.5vw, 1.1rem);
    color: var(--emperor-gold);
    margin-bottom: 6px;
    letter-spacing: 0.1em;
  }
  .kanly-choice.dimmed { opacity: 0.35; cursor: default; }

  #kanly-modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.88);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 150;
    backdrop-filter: blur(4px);
  }
  #kanly-modal.open { display: flex; }
  #kanly-modal h2 {
    font-family: 'Cinzel', serif;
    font-size: clamp(0.82rem, 2.5vw, 1.1rem);
    color: var(--spice);
    margin-bottom: 6px;
    letter-spacing: 0.1em;
  }
  #kanly-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 12px;
  }
  .kanly-choice {
    cursor: pointer;
    border: 2px solid rgba(212,71,10,0.4);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.15s;
    width: 120px;
  }
  .kanly-choice:hover {
    border-color: var(--spice);
    transform: translateY(-3px);
    box-shadow: 0 4px 20px rgba(212,71,10,0.4);
  }
  .kanly-choice img { width: 100%; display: block; }
  .kanly-none {
    font-size: clamp(0.78rem, 1.5vw, 0.9rem);
    color: rgba(245,234,208,0.5);
    font-style: italic;
    padding: 16px;
    font-family: 'Cinzel', serif;
  }


  #tuck-modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.88);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 150;
    backdrop-filter: blur(4px);
  }
  #tuck-modal.open { display: flex; }
  #tuck-modal h2 {
    font-family: 'Cinzel', serif;
    font-size: clamp(0.82rem, 2.5vw, 1.1rem);
    color: var(--sand);
    margin-bottom: 6px;
    letter-spacing: 0.1em;
  }
  #tuck-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 12px;
  }

  /* Choice modal padding override */
  #tuck-modal .modal, #kanly-modal .modal, #intrigue-modal .modal,
  #discard-modal .modal, #steal-solari-modal .modal {
    padding-left: 16px;
    padding-right: 16px;
    padding-bottom: 16px;
  }

  /* Game Over modal specific */
  #modal h2 {
    font-family: 'Cinzel Decorative', serif;
    font-size: clamp(1.1rem, 3vw, 1.8rem);
    color: var(--sand);
    letter-spacing: 0.15em;
    margin-bottom: 8px;
  }


  /* Escalation announcement modal */
  #escalation-modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.92);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 160;
    backdrop-filter: blur(6px);
  }
  #escalation-modal.open { display: flex; }
  #escalation-modal .modal {
    max-width: min(420px, 92vw);
    border-color: var(--emperor-gold);
    box-shadow: 0 0 60px rgba(201,162,39,0.3);
  }
  .esc-icon {
    font-size: clamp(1.4rem, 4vw, 2.2rem);
    margin-bottom: 4px;
  }
  .esc-title {
    font-family: 'Cinzel Decorative', serif;
    font-size: clamp(0.82rem, 2.5vw, 1.1rem);
    color: var(--emperor-gold);
    letter-spacing: 0.1em;
    margin-bottom: 6px;
    text-shadow: 0 0 20px rgba(201,162,39,0.5);
  }
  .esc-card-name {
    font-family: 'Cinzel', serif;
    font-size: clamp(0.82rem, 2.5vw, 1.1rem);
    color: var(--sand-light);
    margin-bottom: 8px;
  }
  .esc-effects {
    background: var(--deep);
    border-radius: 8px;
    padding: clamp(6px, 1.5vw, 12px);
    margin-bottom: 12px;
    font-size: clamp(0.78rem, 1.5vw, 0.9rem);
    line-height: 1.8;
    color: var(--parchment);
    text-align: left;
    font-family: 'Cinzel', serif;
  }
  .esc-effects .eff-line {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    border-bottom: 1px solid rgba(200,169,110,0.1);
  }
  .esc-effects .eff-line:last-child { border-bottom: none; }
  .esc-effects .eff-icon { font-size: 1.1em; flex-shrink: 0; }
  #esc-continue-btn {
    font-family: 'Cinzel', serif;
    letter-spacing: 0.12em;
    background: linear-gradient(135deg, rgba(201,162,39,0.2), rgba(201,162,39,0.05));
    border: 1px solid var(--emperor-gold);
    color: var(--emperor-gold);
    padding: 10px 32px;
    border-radius: 6px;
    cursor: pointer;
    font-size: clamp(0.8rem, 1.8vw, 0.95rem);
    transition: all 0.2s;
  }
  #esc-continue-btn:hover {
    background: rgba(201,162,39,0.25);
    box-shadow: 0 0 20px rgba(201,162,39,0.3);
  }





  #sticky-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--night);
    padding: 0 10vw 8px;
    width: 100%;
    box-shadow: 0 4px 20px rgba(0,0,0,0.6);
  }

  #sticky-header-spacer {
    display: block;
  }

  /* Remove header's own bottom margin since sticky-header handles spacing */
  #sticky-header header {
    margin-bottom: 8px;
  }


  .supply-label {
    font-size: 1rem;
    color: rgba(201,162,39,0.55);
    margin-top: 6px;
    font-family: 'Cinzel', serif;
    letter-spacing: 0.05em;
  }


  /* Rules tab */
  #rules-btn {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 150;
    background: linear-gradient(135deg, #2a2318, #3d3526);
    border: 1px solid rgba(200,169,110,0.4);
    border-radius: 6px;
    padding: 6px 14px;
    color: var(--sand);
    font-family: 'Cinzel', serif;
    font-size: clamp(0.65rem, 1.2vw, 0.8rem);
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.2s;
  }
  #rules-btn:hover {
    background: linear-gradient(135deg, #3d3526, #55462e);
    border-color: rgba(200,169,110,0.7);
  }
  #restart-btn {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 150;
    background: linear-gradient(135deg, #2a2318, #3d3526);
    border: 1px solid rgba(200,169,110,0.4);
    border-radius: 6px;
    padding: 6px 14px;
    color: var(--sand);
    font-family: 'Cinzel', serif;
    font-size: clamp(0.65rem, 1.2vw, 0.8rem);
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.2s;
  }
  #restart-btn:hover {
    background: linear-gradient(135deg, #3d3526, #55462e);
    border-color: rgba(200,169,110,0.7);
  }
  #sound-btn {
    position: fixed;
    bottom: 12px;
    left: 12px;
    z-index: 150;
    border: 1px solid;
    border-radius: 6px;
    padding: 6px 14px;
    font-family: 'Cinzel', serif;
    font-size: clamp(0.65rem, 1.2vw, 0.8rem);
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.2s;
    background: linear-gradient(135deg, #0d2e0d, #1a5c1a);
    border-color: rgba(60,180,60,0.6);
    color: #6dcc6d;
  }
  #sound-btn.sound-off {
    background: linear-gradient(135deg, #2e0d0d, #5c1a1a);
    border-color: rgba(180,60,60,0.6);
    color: #cc6d6d;
  }
  #sound-btn:hover {
    filter: brightness(1.2);
  }
  #music-btn {
    position: fixed;
    bottom: 12px;
    right: 12px;
    z-index: 150;
    border: 1px solid rgba(200,169,110,0.5);
    border-radius: 6px;
    padding: 6px 14px;
    font-family: 'Cinzel', serif;
    font-size: clamp(0.65rem, 1.2vw, 0.8rem);
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.2s;
    background: linear-gradient(135deg, #2a2318, #3d3526);
    color: rgba(200,169,110,0.85);
    text-decoration: none;
    display: inline-block;
  }
  #music-btn:hover {
    filter: brightness(1.2);
    border-color: rgba(200,169,110,0.8);
  }

  #rules-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    z-index: 200;
    overflow-y: auto;
    padding: 20px;
    backdrop-filter: blur(4px);
  }
  #rules-overlay.open { display: block; }
  #rules-overlay .rules-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 520px;
    margin: 0 auto 16px;
  }
  #rules-overlay h2 {
    font-family: 'Cinzel Decorative', serif;
    font-size: clamp(0.9rem, 2vw, 1.2rem);
    color: var(--sand);
    letter-spacing: 0.1em;
  }
  #rules-close {
    background: none;
    border: 1px solid rgba(200,169,110,0.4);
    border-radius: 6px;
    color: var(--sand);
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    padding: 6px 14px;
    cursor: pointer;
    letter-spacing: 0.1em;
  }
  #rules-close:hover { border-color: rgba(200,169,110,0.8); }
  .rules-cards {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    max-width: 520px;
    margin: 0 auto;
  }
  .rules-cards img {
    width: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.6);
  }


  .discard-info {
    font-size: 0.75em;
    color: rgba(245,234,208,0.5);
    margin-left: 10px;
    font-family: 'Cinzel', serif;
    letter-spacing: 0.05em;
  }


  /* ── Why-can't-I-play tooltip ── */
  .card-wrap { position: relative; }
  .cant-play-tip {
    display: block;
    text-align: center;
    margin-top: 4px;
    color: rgba(200,169,110,0.55);
    font-family: 'EB Garamond', serif;
    font-size: 0.6rem;
    font-style: italic;
    letter-spacing: 0.03em;
    pointer-events: none;
    line-height: 1.2;
  }





  #last-log-line {
    font-family: 'EB Garamond', serif;
    font-size: 0.95rem;
    font-style: italic;
    color: rgba(245,234,208,0.45);
    text-align: center;
    padding: 0 8px;
    min-height: 0;
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

