/* Russian Roulette - Responsive Landscape & CRT Retro Style */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap');

:root {
  --bg-dark: #08090c;
  --bg-panel: #13151b;
  --panel-border: #282f3c;
  --accent-gold: #e2a838;
  --accent-gold-dark: #8c5d14;
  --accent-red: #d93838;
  --accent-blue: #3ba4e6;
  --accent-green: #38b058;
  --text-main: #eceeef;
  --text-muted: #8c93a0;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: 'Press Start 2P', monospace, sans-serif;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================
   1. LANDSCAPE ENFORCER (Wajib Miringin di HP)
   ========================================== */
.landscape-enforcer {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: #08090c;
  z-index: 99999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

.enforcer-box {
  background: var(--bg-panel);
  border: 4px solid var(--accent-gold);
  padding: 24px;
  max-width: 380px;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.rotate-phone-anim {
  font-size: 42px;
  animation: phone-rotate 2s infinite ease-in-out;
}

@keyframes phone-rotate {
  0%, 20% { transform: rotate(0deg); }
  50%, 70% { transform: rotate(-90deg); }
  90%, 100% { transform: rotate(0deg); }
}

.enforcer-title {
  font-size: 11px;
  color: var(--accent-gold);
  line-height: 1.4;
}

.enforcer-desc {
  font-size: 8px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Show enforcer when screen is portrait or mobile width < 800px in portrait */
@media screen and (orientation: portrait) and (max-width: 900px) {
  .landscape-enforcer {
    display: flex !important;
  }
}

/* ==========================================
   2. APP CONTAINER & FULLSCREEN FIT
   ========================================== */
.app-container {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  position: relative;
}

.hidden {
  display: none !important;
}

/* Top Floating Controls */
.top-bar-actions {
  position: absolute;
  top: 8px;
  right: 12px;
  display: flex;
  gap: 8px;
  z-index: 50;
}

.btn-icon {
  background: #1b1f28;
  border: 2px solid var(--panel-border);
  color: var(--accent-gold);
  font-size: 11px;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 4px;
}
.btn-icon:hover {
  background: #282f3e;
}

/* ==========================================
   3. MENU & CHARACTER SELECTOR
   ========================================== */
.menu-wrapper {
  width: 100%;
  max-width: 760px;
  height: 94vh;
  max-height: 540px;
  background: var(--bg-panel);
  border: 3px solid var(--panel-border);
  box-shadow: 0 0 35px rgba(0, 0, 0, 0.9);
  display: grid;
  grid-template-columns: 240px 1fr;
  padding: 14px;
  gap: 16px;
  overflow-y: auto;
}

@media (max-width: 680px) {
  .menu-wrapper {
    grid-template-columns: 1fr;
    height: 96vh;
  }
}

/* Left: Character Carousel Preview */
.char-select-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #0b0c10;
  border: 2px solid #20242e;
  padding: 10px;
}

.char-preview-crt {
  width: min(256px, 40vh);
  height: min(256px, 40vh);
  border: 3px solid #33271e;
  position: relative;
  background: #000;
  line-height: 0;
}

#charPreviewCanvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.char-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 6px;
}

.char-name-badge {
  text-align: center;
}
.char-name {
  font-size: 9px;
  color: var(--accent-gold);
  margin-bottom: 2px;
}
.char-title {
  font-size: 7px;
  color: var(--text-muted);
}

/* Right: Form & Mode Selection */
.menu-form-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
}

.title-header {
  font-size: 13px;
  color: var(--accent-gold);
  text-shadow: 2px 2px 0 #000;
  margin-bottom: 2px;
}

.pixel-input {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  background: #0a0b0e;
  border: 2px solid #29303d;
  color: #fff;
  padding: 8px;
  outline: none;
  width: 100%;
}
.pixel-input:focus {
  border-color: var(--accent-gold);
}

.player-count-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0b0d12;
  border: 1px solid #232832;
  padding: 6px 10px;
  font-size: 8px;
}

.count-badge {
  color: var(--accent-gold);
  font-size: 11px;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-pixel {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 10px 12px;
  cursor: pointer;
  border: 2px solid #000;
  box-shadow: 3px 3px 0 #000;
  outline: none;
  transition: transform 0.05s;
}
.btn-pixel:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #000;
}
.btn-pixel:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.btn-gold { background: var(--accent-gold); color: #160e05; }
.btn-red { background: var(--accent-red); color: #fff; }
.btn-blue { background: var(--accent-blue); color: #071924; }
.btn-green { background: var(--accent-green); color: #051d0e; }
.btn-dark { background: #232733; color: #ced3df; }

/* ==========================================
   4. IN-GAME ARENA — CANVAS LAYAR PENUH + HUD OVERLAY
   ========================================== */
.arena-full {
  position: fixed;
  inset: 0;
  background: #000;
  overflow: hidden;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  cursor: none; /* crosshair digambar di canvas */
  touch-action: none;
}

.hud-top, .hud-roster, .hud-info, .hud-bottom, .hud-hint {
  position: absolute;
  z-index: 5;
  pointer-events: none;
}
.hud-top > *, .hud-roster, .hud-info, .hud-bottom > * { pointer-events: auto; }

.hud-top {
  top: 8px;
  left: 10px;
  right: 270px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.hud-pill {
  background: rgba(10, 8, 12, 0.72);
  border: 2px solid rgba(226, 168, 56, 0.35);
  padding: 6px 8px;
  font-size: 8px;
  white-space: nowrap;
}
.hud-pill strong { color: var(--accent-gold); }
.hud-link { cursor: pointer; color: var(--accent-blue); }

.turn-marquee {
  flex: 1;
  text-align: center;
  padding: 6px 10px;
  font-size: 9px;
  border: 2px solid #000;
  background: rgba(24, 56, 32, 0.88);
  color: #6cf08a;
  box-shadow: 0 0 12px rgba(76, 230, 117, 0.25);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.turn-marquee.opponent { background: rgba(56, 28, 28, 0.88); color: #ff7a7a; box-shadow: none; }
.turn-marquee.dealer { background: rgba(60, 46, 14, 0.9); color: #ffd36a; box-shadow: none; }

.hud-roster {
  top: 48px;
  left: 10px;
  width: 170px;
  max-height: calc(100% - 190px);
  overflow-y: auto;
  background: rgba(10, 8, 12, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.08);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#rosterList { display: flex; flex-direction: column; gap: 4px; }

.table-title {
  font-size: 7px;
  color: var(--accent-gold);
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 4px;
}

.player-card-chip {
  background: rgba(13, 15, 20, 0.85);
  border: 1px solid #20242e;
  padding: 5px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 7px;
  cursor: pointer;
}
.player-card-chip:hover { border-color: var(--accent-gold); }
.player-card-chip.active-turn { border-color: #4ce675; background: rgba(17, 40, 24, 0.9); }
.player-card-chip.target-selected { border-color: var(--accent-red); box-shadow: 0 0 6px rgba(217, 56, 56, 0.6); }
.player-card-chip.eliminated { opacity: 0.35; filter: grayscale(100%); }
.chip-name { color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 96px; }
.chip-hp { color: var(--accent-red); letter-spacing: 1px; font-size: 6px; }

.hud-info {
  top: 48px;
  right: 10px;
  width: 200px;
  max-height: calc(100% - 190px);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cylinder-status-card {
  background: rgba(10, 8, 12, 0.72);
  border: 2px solid rgba(255, 255, 255, 0.08);
  padding: 6px;
  font-size: 7px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.status-row { display: flex; justify-content: space-between; }
.stat-highlight { color: var(--accent-gold); }
.stat-danger { color: var(--accent-red); }

.battle-log {
  max-height: 150px;
  background: rgba(6, 6, 8, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.06);
  padding: 6px;
  font-family: 'VT323', monospace;
  font-size: 14px;
  color: #c4cad6;
  overflow-y: auto;
  line-height: 1.2;
  display: flex;
  flex-direction: column;
}
.battle-log p:first-child { color: #fff; }
.battle-log p:nth-child(n+5) { opacity: 0.55; }

.hud-bottom {
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.primary-actions { display: flex; gap: 8px; align-items: flex-end; }
.primary-actions .btn-pixel { box-shadow: 3px 3px 0 #000; }
.btn-shoot { font-size: 11px; padding: 12px 16px; min-width: 210px; }

.cards-hand-deck {
  display: flex;
  gap: 6px;
  align-items: center;
  background: rgba(10, 8, 12, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.08);
  padding: 6px;
  min-width: 140px;
}
#cardsHandContainer { display: flex; gap: 5px; }
.hand-label { font-size: 7px; color: var(--accent-gold); white-space: nowrap; writing-mode: vertical-rl; transform: rotate(180deg); letter-spacing: 2px; }
.hand-empty { font-size: 6px; color: var(--text-muted); }

/* ---------- Kartu taktis (pixel art, tanpa emoji) ---------- */
#cardsHandContainer { display: flex; gap: 2px; align-items: flex-end; padding: 0 4px; }

.pixel-card {
  --type: #3ba4e6;
  --fan: 0deg;
  --lift: 0px;
  position: relative;
  width: 68px;
  height: 96px;
  padding: 4px;
  margin: 0 -3px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  font-family: 'Press Start 2P', monospace;
  background: #efe6cf;
  border: 2px solid #0a0606;
  box-shadow: inset 0 0 0 2px var(--type), inset 0 0 0 4px #efe6cf, inset 0 0 0 5px rgba(0,0,0,0.25), 3px 3px 0 #000;
  transform: translateY(var(--lift)) rotate(var(--fan));
  transform-origin: 50% 120%;
  transition: transform 0.12s ease-out, filter 0.12s;
  cursor: pointer;
  color: #1a0e08;
}
.pixel-card.type-attack { --type: #d93838; }
.pixel-card.type-info { --type: #3ba4e6; }
.pixel-card.type-heal { --type: #38b058; }
.pixel-card.type-control { --type: #a066e8; }

.pixel-card:hover:not(.disabled), .pixel-card:focus-visible {
  transform: translateY(-14px) rotate(0deg) scale(1.06);
  z-index: 3;
  outline: none;
  filter: drop-shadow(0 0 6px var(--type));
}
.pixel-card.disabled { filter: grayscale(0.7) brightness(0.75); cursor: not-allowed; }

.card-top { display: flex; justify-content: space-between; align-items: center; padding: 2px 2px 0; }
.card-key {
  width: 12px; height: 12px;
  display: grid; place-items: center;
  font-size: 6px;
  color: #efe6cf;
  background: #0a0606;
}
.card-type { font-size: 5px; color: var(--type); text-shadow: 1px 1px 0 rgba(0,0,0,0.15); }
.card-art {
  flex: 1;
  display: grid;
  place-items: center;
  margin: 0 2px;
  background: #1e1726;
  border: 2px solid #0a0606;
  box-shadow: inset 0 0 0 1px var(--type);
}
.card-art img { width: 40px; height: 40px; image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
.card-title { font-size: 6px; text-align: center; padding-bottom: 3px; letter-spacing: 0.5px; }

.card-tip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  width: 170px;
  padding: 7px 8px;
  font-family: 'VT323', monospace;
  font-size: 15px;
  line-height: 1.1;
  text-align: left;
  color: #e8e2d4;
  background: rgba(10, 8, 12, 0.95);
  border: 2px solid var(--type);
  box-shadow: 3px 3px 0 #000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
}
.card-tip strong { display: block; font-family: 'Press Start 2P', monospace; font-size: 7px; font-weight: normal; color: var(--type); margin-bottom: 4px; }
.pixel-card:hover .card-tip { opacity: 1; }

/* Dipakai: melayang ke meja & memudar */
@keyframes card-use {
  0% { transform: translateY(-14px) scale(1.06); opacity: 1; }
  100% { transform: translateY(-140px) scale(0.6) rotate(12deg); opacity: 0; }
}
.pixel-card.used { animation: card-use 0.28s ease-in forwards; pointer-events: none; }

/* Bukan giliranmu: kartu menggeleng */
@keyframes card-shake {
  0%, 100% { transform: translateY(var(--lift)) rotate(var(--fan)); }
  25% { transform: translateY(var(--lift)) rotate(calc(var(--fan) - 6deg)); }
  75% { transform: translateY(var(--lift)) rotate(calc(var(--fan) + 6deg)); }
}
.pixel-card.shake { animation: card-shake 0.25s; }

/* Kartu "dibagikan" bandar: terbang dari atas & membalik */
@keyframes card-deal-in {
  0% { transform: translateY(-160px) rotateY(180deg) scale(0.6); opacity: 0; }
  60% { transform: translateY(6px) rotateY(90deg) scale(1.05); opacity: 1; }
  100% { transform: translateY(var(--lift)) rotate(var(--fan)); }
}
.pixel-card.deal-in { animation: card-deal-in 0.55s ease-out both; }

.emotes-row { display: flex; gap: 4px; }
.emote-btn {
  background: rgba(27, 31, 40, 0.85);
  border: 1px solid #333a4a;
  font-size: 14px;
  padding: 4px 6px;
  cursor: pointer;
}

.hud-hint {
  left: 50%;
  top: 44px;
  transform: translateX(-50%);
  font-size: 7px;
  color: rgba(240, 230, 210, 0.55);
  white-space: nowrap;
  text-shadow: 1px 1px 0 #000;
}

/* Layar kecil (HP landscape) */
@media (max-height: 480px), (max-width: 820px) {
  .hud-roster { width: 130px; top: 40px; }
  .hud-info { width: 150px; top: 40px; }
  .battle-log { max-height: 80px; font-size: 12px; }
  .hud-top { top: 4px; right: 230px; gap: 4px; }
  .hud-pill, .turn-marquee { font-size: 6px; padding: 4px 6px; }
  .btn-shoot { min-width: 150px; font-size: 8px; padding: 9px 10px; }
  .primary-actions .btn-pixel { font-size: 7px; }
  .pixel-card { width: 52px; height: 74px; }
  .card-art img { width: 32px; height: 32px; }
  .card-tip { width: 140px; font-size: 13px; }
  .emotes-row, .hud-hint { display: none; }
}

/* Target Selector Modal */
.target-picker-modal {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.target-picker-card {
  background: var(--bg-panel);
  border: 3px solid var(--accent-red);
  padding: 16px;
  max-width: 360px;
  width: 90%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.targets-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 12px;
}
.modal-card {
  background: var(--bg-panel);
  border: 4px solid var(--accent-gold);
  padding: 18px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-title { font-size: 12px; color: var(--accent-gold); }
.modal-text { font-size: 8px; color: var(--text-muted); line-height: 1.5; }
.modal-buttons { display: flex; gap: 8px; justify-content: center; }

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 7px;
}
.leaderboard-table th {
  color: var(--accent-gold);
  border-bottom: 2px solid var(--panel-border);
  padding: 4px;
}
.leaderboard-table td {
  padding: 4px;
  border-bottom: 1px solid #1a1e27;
}

.pixel-card:first-child .card-tip { left: 0; transform: none; }
/* Tangan kartu: tanpa panel/label, kartu berdiri sendiri seperti dipegang */
.cards-hand-deck { background: none; border: none; padding: 0 0 2px 6px; min-width: 0; }
.hand-label { display: none; }
.hand-empty {
  font-size: 7px; color: rgba(240, 230, 210, 0.7);
  background: rgba(10, 8, 12, 0.6); padding: 6px 8px; border: 2px solid rgba(255,255,255,0.08);
}
