/**
 * PAIRS Skin - 8bit Edition (Visuals only)
 */

:root {
  --fc-white: #ffffff;
  --fc-black: #000000;
  --fc-yellow: #ffff00;
  --fc-red: #da251d;
  --fc-blue: #000088;
  --pixel-font: 'BIZ UD Gothic', 'Yu Gothic UI', 'MS Gothic', 'Courier New', monospace;
  --global-mono-font: 'JetBrains Mono', 'Courier New', 'BIZ UD Gothic', 'MS Gothic', monospace;
  
  --fz-tiny: 8px;
  --fz-small: 10px;
  --fz-normal: 12px;
  --fz-large: 16px;
  --fz-xl: 20px;
  --fz-title: 3.5rem;
}

body.famicom-theme { 
  background-color: var(--fc-black) !important; color: var(--fc-white);
  font-family: var(--global-mono-font) !important;
  font-size: var(--fz-large);
}

/* --- LOGO / HEADER --- */
.famicom-theme .app-header { background: #000; border-bottom: 2px solid #333; }
.famicom-theme .app-logo-container { font-family: var(--pixel-font) !important; }
.famicom-theme .logo-brand { font-size: var(--fz-normal); color: var(--fc-yellow); text-transform: lowercase; }
.famicom-theme .logo-game { font-size: var(--fz-small); color: var(--fc-white); text-transform: uppercase; }

/* --- TITLE VIEW --- */
.famicom-theme #title-screen { background: var(--fc-blue); border: 4px inset #0000ff; }
.famicom-theme .lang-btn { background: none; border: none; color: #888; font-family: var(--pixel-font); font-size: var(--fz-small); }
.famicom-theme .lang-btn.active { color: var(--fc-yellow); text-decoration: underline; }
.famicom-theme .game-title { 
  font-family: var(--pixel-font) !important; font-size: var(--fz-title); 
  color: var(--fc-yellow); text-shadow: 4px 4px var(--fc-red); letter-spacing: -4px; 
}
.famicom-theme #start-prompt { font-weight: 700; font-size: var(--fz-xl); color: var(--fc-white); text-transform: uppercase; font-family: var(--pixel-font) !important; }

/* --- MENU & SETTINGS --- */
.famicom-theme .menu-item {
  background: none; border: none; color: var(--fc-white);
  font-size: var(--fz-large); font-weight: 700; letter-spacing: 1.5px;
}
.famicom-theme .menu-item:hover { color: var(--fc-yellow); }

.famicom-theme .sl { font-family: var(--pixel-font) !important; font-size: var(--fz-small); color: var(--fc-white); text-transform: uppercase; }
.famicom-theme .gauge-btn { background: none; border: none; color: #fff; opacity: 0.45; }
.famicom-theme .gauge-btn.active { opacity: 1; color: var(--fc-yellow); filter: drop-shadow(0 0 2px rgba(255,255,0,0.5)); }

/* --- LARGE SETUP MODAL --- */
.famicom-theme #online-setup { background: rgba(0,0,0,0.85); }
.famicom-theme .large-modal { background: var(--fc-blue); border: 4px double var(--fc-white); }
.famicom-theme .modal-title { font-family: var(--pixel-font); font-size: var(--fz-large); color: var(--fc-yellow); }
.famicom-theme .setup-section-title {
  background: rgba(255,255,255,0.1); font-family: var(--pixel-font); font-size: var(--fz-small); color: var(--fc-white);
  border-left: 4px solid var(--fc-yellow); text-transform: uppercase;
}
.famicom-theme .retro-select {
  background: #000; border: 1px solid #fff; color: var(--fc-white);
  font-family: var(--global-mono-font); font-size: var(--fz-normal); font-weight: bold;
}
.famicom-theme .room-id-area { border-top: 2px dashed rgba(255,255,255,0.2); }
.famicom-theme .retro-input { 
  background: #000; border: 2px solid var(--fc-white); color: var(--fc-yellow);
  font-family: var(--global-mono-font); font-size: var(--fz-xl); font-weight: bold;
  letter-spacing: 4px;
}
.famicom-theme .retro-input:focus { border-color: var(--fc-yellow); }
.famicom-theme .mini-btn { font-size: var(--fz-small); font-family: var(--pixel-font) !important; }

/* --- HUD / COMMON UI --- */
.famicom-theme .p-score { font-size: 24px; }
.famicom-theme .message-box { font-size: var(--fz-normal); border: 2px solid var(--fc-white); letter-spacing: 1px; font-weight: bold; }
.famicom-theme .blink-fast { animation: blink 0.8s infinite; text-shadow: 0 0 8px rgba(255,255,255,0.65); }
@keyframes blink { 0%, 100% { opacity: 0.65; } 50% { opacity: 1; } }

.famicom-theme .screen-container { border: 4px solid #555; background: var(--fc-black); }
.famicom-theme .hud { border-bottom: 4px solid var(--fc-white); }
.famicom-theme .btn-retro { 
  background: var(--fc-white); color: var(--fc-black); border: 4px outset #ccc; 
  font-size: var(--fz-large); font-family: var(--pixel-font) !important; letter-spacing: 1px; 
}
.famicom-theme .btn-retro:active { border-style: inset; }
.famicom-theme .footer-info { font-size: var(--fz-tiny); opacity: 0.7; letter-spacing: 1px; color: #fff; }

/* --- GAME CARDS --- */
.famicom-theme .card-face { border: 2px solid var(--fc-white); }
.famicom-theme .card-front { background-color: var(--fc-red) !important; background-image: repeating-linear-gradient(45deg, #a00, #a00 2px, var(--fc-red) 2px, var(--fc-red) 4px); }
.famicom-theme .card-back { background: var(--fc-black) !important; }
.famicom-theme .concept-text { 
  font-family: var(--global-mono-font) !important; 
  font-size: var(--fz-small); /* Smaller for definitions */
  line-height: 1.2; 
  color: var(--fc-white); 
  font-weight: 700; 
  letter-spacing: -0.2px; 
  /* Handle long definitions gracefully */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

/* ============================================================
   V5 QUALITY PASS - 8bit (CRT feel, richer cards, capture/territory,
   result screen, items). Overrides earlier rules by cascade order.
   ============================================================ */

body.famicom-theme {
  --p1-color: #2f7bff;
  --p2-color: #ff3344;
}

/* CRT scanlines + vignette over the play surface */
.famicom-theme .screen-container::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none; z-index: 60;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.16) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 58%, rgba(0,0,0,0.38) 100%);
}

/* Title: layered pixel shadow + gentle float */
.famicom-theme .game-title {
  text-shadow: 3px 3px 0 var(--fc-red), 6px 6px 0 rgba(0,0,0,0.55);
  animation: ggTitleFloat 2.6s ease-in-out infinite;
}
@keyframes ggTitleFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

/* Menu cursor */
.famicom-theme .menu-item:hover::before { content: "▶ "; color: var(--fc-yellow); }

/* HUD: clear active-player state */
.famicom-theme .p-panel { opacity: 0.5; transition: opacity 0.25s; }
.famicom-theme .p-panel.active { opacity: 1; }
.famicom-theme .p-panel.active .p-name { color: var(--fc-yellow); text-shadow: 0 0 6px rgba(255,255,0,0.6); }
.famicom-theme #player-1-panel.active .p-name { color: var(--p1-color); text-shadow: 0 0 6px var(--p1-color); }
.famicom-theme #player-2-panel.active .p-name { color: var(--p2-color); text-shadow: 0 0 6px var(--p2-color); }
.famicom-theme .game-timer { font-family: var(--global-mono-font); font-size: var(--fz-xl); font-weight: bold; color: var(--fc-white); text-shadow: 0 0 8px rgba(255,255,255,0.5); }
.famicom-theme .combo-indicator { font-family: var(--pixel-font); color: var(--fc-yellow); text-shadow: 1px 1px 0 var(--fc-red); }
.famicom-theme .message-box { background: rgba(0,0,0,0.55); }

/* Cards: Vietnamese-flag gold star face, hover lift, glow on capture */
.famicom-theme .card:not(.is-flipped):not(.is-matched):hover { transform: translateY(-3px); }
.famicom-theme .card-front {
  background-color: var(--fc-red) !important;
  background-image:
    linear-gradient(135deg, rgba(255,255,255,0.28) 0%, rgba(255,255,255,0) 40%),
    repeating-linear-gradient(45deg, rgba(0,0,0,0.22) 0 2px, transparent 2px 4px);
  box-shadow: inset 0 0 0 3px rgba(0,0,0,0.35), inset 0 0 0 5px rgba(255,255,255,0.22), 0 2px 0 rgba(0,0,0,0.5);
}
.famicom-theme .card-front::after {
  content: "★";
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #ffe14d; font-size: 22px; line-height: 1;
  text-shadow: 1px 2px 0 rgba(0,0,0,0.45);
}
.famicom-theme .card-back {
  background: linear-gradient(180deg, #000022 0%, #000000 70%) !important;
  box-shadow: inset 0 0 10px rgba(255,255,255,0.12);
}
.famicom-theme .card.is-matched .card-face { box-shadow: 0 0 14px var(--capture-color); }

/* Lock item */
.famicom-theme .item-btn {
  background: #000; color: var(--fc-white); border: 2px solid var(--fc-white);
  font-family: var(--global-mono-font); font-size: var(--fz-small); font-weight: bold;
}
.famicom-theme .item-btn.arming { border-color: var(--fc-yellow); color: var(--fc-yellow); animation: blink 0.5s infinite; }

/* Score popup */
.famicom-theme .score-pop {
  font-family: var(--pixel-font); font-size: var(--fz-large);
  color: var(--fc-yellow); text-shadow: 2px 2px 0 #000;
}

/* Result screen */
.famicom-theme .result-rank { font-family: var(--pixel-font); color: var(--fc-yellow); text-shadow: 4px 4px 0 var(--fc-red); }
.famicom-theme .result-rank.rank-S { color: #ffd700; animation: ggTitleFloat 1.6s ease-in-out infinite; }
.famicom-theme .result-new-record { color: var(--fc-yellow); font-family: var(--pixel-font); font-size: var(--fz-normal); }
.famicom-theme .result-stats .rs-row { font-family: var(--global-mono-font); font-size: var(--fz-normal); color: var(--fc-white); border-bottom: 1px dashed rgba(255,255,255,0.2); }
.famicom-theme .result-stats .rs-value { color: var(--fc-yellow); font-weight: bold; }
.famicom-theme .result-words-title { font-family: var(--pixel-font); font-size: var(--fz-small); color: var(--fc-white); text-transform: uppercase; }
.famicom-theme .result-words li { font-family: var(--global-mono-font); font-size: var(--fz-normal); color: var(--fc-white); border-bottom: 1px solid rgba(255,255,255,0.12); }
.famicom-theme .result-words .rw-vi { color: var(--fc-yellow); }
.famicom-theme .result-area-bar { border: 2px solid var(--fc-white); }

/* ============================================================
   V5.1 - game top bar / settings modal entry / sound toggle (8bit)
   ============================================================ */
.famicom-theme .game-topbar { background: rgba(0,0,0,0.5); border-bottom: 2px solid var(--fc-white); }
.famicom-theme .topbar-btn { background: #000; color: var(--fc-white); border: 2px solid var(--fc-white); font-family: var(--pixel-font) !important; font-size: var(--fz-small); }
.famicom-theme .topbar-btn:active { background: var(--fc-white); color: #000; }
.famicom-theme .topbar-title { font-family: var(--pixel-font); font-size: var(--fz-small); color: var(--fc-yellow); letter-spacing: 3px; }
.famicom-theme .btn-settings-entry { background: none; border: 2px dashed rgba(255,255,255,0.55); color: var(--fc-white); font-family: var(--pixel-font) !important; font-size: var(--fz-normal); letter-spacing: 1px; }
.famicom-theme .btn-settings-entry:hover { border-color: var(--fc-yellow); color: var(--fc-yellow); }
.famicom-theme .sound-toggle { background: #000; border: 1px solid #fff; color: var(--fc-yellow); font-family: var(--global-mono-font); font-weight: bold; }
.famicom-theme .sound-toggle.is-off { color: #777; }

/* V5.2 - larger readable language switcher */
.famicom-theme .lang-btn { font-size: var(--fz-normal); padding: 6px 10px; }
