* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #1a3d1a;
  background-image: radial-gradient(ellipse at center, #2d5a2d 0%, #0f2a0f 100%);
  color: #e0d6c2;
  font-family: 'Georgia', serif;
  min-height: 100vh;
  overflow: hidden;
  user-select: none;
}

.hidden { display: none !important; }

/* START SCREEN */
#start-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100vh; gap: 20px; overflow-y: auto;
}
.title {
  font-size: 72px; letter-spacing: 8px; text-shadow: 0 0 30px rgba(255,200,50,.6), 0 0 60px rgba(255,150,0,.3);
  color: #f0e0b0;
}
.title span { color: #ff6b35; }
.subtitle { font-size: 18px; color: #a09880; letter-spacing: 4px; text-transform: uppercase; }
.difficulty-select { display: flex; gap: 12px; margin: 20px 0; }
.diff-btn {
  padding: 12px 28px; background: #2a2a1a; border: 2px solid #665; color: #c0b090;
  font-size: 16px; cursor: pointer; border-radius: 6px; transition: all .2s;
  font-family: inherit;
}
.diff-btn:hover, .diff-btn.selected { background: #443a20; border-color: #ff6b35; color: #fff; }
.rules-box {
  max-width: 640px; width: 90%; background: rgba(0,0,0,.25); border: 1px solid #443;
  border-radius: 10px; padding: 20px 24px; margin: 8px 0;
}
.rules-box h2 { font-size: 16px; color: #ff6b35; letter-spacing: 3px; text-transform: uppercase; margin-bottom: 14px; }
.rules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.rule-card {
  background: rgba(255,255,255,.04); border: 1px solid #443; border-radius: 6px;
  padding: 10px 12px; text-align: left;
}
.rule-icon { font-size: 22px; margin-bottom: 2px; }
.rule-icon.hearts { color: #c00; }
.rule-icon.diamonds { color: #c00; }
.rule-icon.clubs { color: #333; }
.rule-title { font-size: 13px; font-weight: bold; color: #e0d6c2; margin-bottom: 4px; }
.rule-desc { font-size: 11px; color: #a09880; line-height: 1.5; }
.rules-extras { font-size: 12px; color: #a09880; line-height: 2; border-top: 1px solid #332; padding-top: 10px; }
.rules-extras b { color: #d0c8b0; }

#rules-toggle {
  position: fixed; top: 8px; right: 12px; z-index: 40;
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(0,0,0,.4); border: 1px solid #554; color: #a09880;
  font-size: 18px; cursor: pointer; transition: all .2s;
  display: flex; align-items: center; justify-content: center;
}
#rules-toggle:hover { background: rgba(255,107,53,.2); border-color: #ff6b35; color: #fff; }
.rules-modal-content { max-width: 500px; text-align: left; }
.rules-modal-content h2 { text-align: center; }
.rules-ref { line-height: 2; font-size: 13px; color: #c0b8a0; }
.rules-ref b { color: #e0d6c2; }
.rules-ref hr { border: none; border-top: 1px solid #443; margin: 8px 0; }
.rules-ref p { margin: 4px 0; }
.rules-modal-content .action-btn { display: block; margin: 16px auto 0; }

@media (max-width: 500px) {
  .rules-grid { grid-template-columns: 1fr; }
  .title { font-size: 42px; letter-spacing: 4px; }
}
#deal-btn {
  margin-top: 20px; padding: 16px 60px; font-size: 24px; background: linear-gradient(135deg, #ff6b35, #c0441a);
  border: none; color: #fff; border-radius: 8px; cursor: pointer; letter-spacing: 4px;
  font-family: inherit; transition: transform .15s, box-shadow .15s;
  box-shadow: 0 4px 20px rgba(255,107,53,.4);
}
#deal-btn:hover { transform: scale(1.05); box-shadow: 0 6px 30px rgba(255,107,53,.6); }

/* GAME SCREEN */
#game-screen { height: 100vh; display: flex; flex-direction: column; position: relative; }

#screen-flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 100;
  background: rgba(255,0,0,.3); opacity: 0; transition: opacity .1s;
}
#screen-flash.active { opacity: 1; }

#floating-texts { position: fixed; inset: 0; pointer-events: none; z-index: 99; }
.float-text {
  position: absolute; font-size: 28px; font-weight: bold; animation: floatUp 1.2s forwards;
  text-shadow: 0 2px 8px rgba(0,0,0,.8);
}
@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-80px) scale(1.3); }
}

/* TURN INDICATOR */
#turn-indicator {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%);
  z-index: 45; padding: 6px 24px; border-radius: 20px;
  font-size: 14px; font-weight: bold; letter-spacing: 3px;
  text-transform: uppercase; pointer-events: none;
  animation: turnPulse 2s infinite;
}
#turn-indicator.player-turn {
  background: rgba(50,180,50,.25); border: 1px solid #4a4; color: #8f8;
}
#turn-indicator.opponent-turn {
  background: rgba(180,50,50,.25); border: 1px solid #a44; color: #f88;
}
@keyframes turnPulse {
  0%, 100% { opacity: .8; }
  50% { opacity: 1; }
}

/* TOP BAR */
#top-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 16px; background: rgba(0,0,0,.3); gap: 16px;
}
.player-info { flex: 1; }
.player-info-right { text-align: right; }
.player-name { font-size: 13px; letter-spacing: 2px; color: #a09880; margin-bottom: 4px; }
.hp-bar-container {
  height: 28px; background: #1a1a10; border-radius: 14px; overflow: hidden;
  border: 1px solid #444; position: relative;
}
.hp-bar {
  height: 100%; background: linear-gradient(90deg, #d44, #c33);
  transition: width .5s; width: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: bold; color: #fff; text-shadow: 0 1px 3px #000;
  min-width: 30px;
}
.hp-bar.player-hp { background: linear-gradient(90deg, #3a3, #2a2); }
.hp-bar.flash { animation: hpFlash .3s; }
@keyframes hpFlash { 50% { filter: brightness(2); } }
.status-icons { display: flex; gap: 12px; margin-top: 4px; font-size: 13px; }
.player-info-right .status-icons { justify-content: flex-end; }
.status-item { color: #998; }
.status-item.active { color: #ffcc00; text-shadow: 0 0 8px #ff6; }
.deck-info { font-size: 24px; text-align: center; min-width: 80px; }
#deck-count span { font-size: 16px; vertical-align: middle; }

/* HANDS */
#opponent-hand, #player-hand {
  display: flex; justify-content: center; padding: 8px; min-height: 110px;
  align-items: flex-end; perspective: 800px;
}
#opponent-hand { padding-top: 4px; align-items: flex-start; }
#player-hand { padding-bottom: 12px; padding-top: 4px; }

/* CARDS */
.card {
  width: 72px; height: 100px; border-radius: 6px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 14px; cursor: default;
  transition: transform .3s ease, box-shadow .3s ease, margin .2s, opacity .3s;
  position: relative; flex-shrink: 0;
}
.card-front {
  background: #fff; color: #333; border: 2px solid #999;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.card-back {
  background: linear-gradient(135deg, #2244aa, #1a3388);
  border: 2px solid #4466cc; color: #6688dd; font-size: 28px;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.card-front.red { color: #c00; }
.card-front.black { color: #222; }
.card .card-value { font-size: 18px; font-weight: bold; line-height: 1; }
.card .card-suit { font-size: 22px; line-height: 1; }
.card .card-corner { position: absolute; font-size: 10px; line-height: 1; }
.card .card-corner.tl { top: 3px; left: 4px; }
.card .card-corner.br { bottom: 3px; right: 4px; transform: rotate(180deg); }

.card.playable { cursor: pointer; }
.card.playable:hover { transform: translateY(-16px) scale(1.05); box-shadow: 0 8px 20px rgba(0,0,0,.5); z-index: 10; }
.card.selected { transform: translateY(-24px) scale(1.08); box-shadow: 0 8px 25px rgba(255,200,0,.5); border-color: #fc0; z-index: 11; }
.card.disabled-club {
  cursor: not-allowed; opacity: 0.4; filter: grayscale(0.5);
}
.card.disabled-club:hover { transform: none; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.card.glow-guard { box-shadow: 0 0 15px 5px rgba(255,50,50,.6); }
.card.glow-counter { box-shadow: 0 0 15px 5px rgba(100,50,255,.6); }
.card.glow-guard:hover, .card.glow-counter:hover { transform: translateY(-14px); }

/* Card fan rotation for hand */
.card.fan { transform-origin: bottom center; }

/* Card animations */
.card-enter { animation: cardSlideIn .4s ease-out; }
@keyframes cardSlideIn {
  from { transform: translateX(-60px) translateY(-30px) scale(.5); opacity: 0; }
  to { transform: translateX(0) translateY(0) scale(1); opacity: 1; }
}
.card-play-anim {
  animation: cardPlaySlide .4s ease-in forwards;
}
@keyframes cardPlaySlide {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: translateY(-40px) scale(.85); opacity: 0; }
}
.card-discard {
  animation: cardDiscard .3s ease-in forwards;
}
@keyframes cardDiscard {
  to { transform: scale(.3); opacity: 0; }
}

/* Played card slide-in */
.played-slot .card {
  animation: playedAppear .3s ease-out;
}
@keyframes playedAppear {
  from { transform: translateY(30px) scale(.7); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

/* MIDDLE */
#middle-area {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 20px;
  padding: 0 16px;
}
#play-area { display: flex; align-items: center; gap: 20px; }
.played-slot { width: 72px; height: 100px; border: 2px dashed #4a4a30; border-radius: 6px; }
.played-slot .card { margin: 0; }
.charge-pile {
  min-width: 90px; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.charge-label { font-size: 11px; color: #887; letter-spacing: 1px; }
.charge-total-value {
  font-size: 22px; font-weight: bold; color: #ffcc00;
  text-shadow: 0 0 8px rgba(255,200,0,.5);
  min-height: 28px;
}
.charge-pile .card { width: 50px; height: 70px; font-size: 11px; margin-top: -50px; }
.charge-pile .card:first-of-type { margin-top: 0; }
.charge-pile .card .card-suit { font-size: 16px; }
.charge-pile .card .card-value { font-size: 13px; }

/* COMBO TRACKER */
#combo-tracker {
  text-align: center; padding: 4px; font-size: 13px; color: #998;
  min-height: 24px;
}
#combo-label { color: #ff6b35; }
#combo-values { letter-spacing: 2px; }

/* PREPARED GUARD */
#prepared-guard {
  text-align: center; padding: 4px 12px;
  font-size: 14px; color: #4f4; font-weight: bold;
  background: rgba(0,100,0,.2); border: 1px solid #4a4;
  border-radius: 6px; margin: 2px auto; width: fit-content;
  animation: guardPulse 2s infinite;
}
@keyframes guardPulse {
  0%, 100% { box-shadow: 0 0 5px rgba(0,255,0,.2); }
  50% { box-shadow: 0 0 15px rgba(0,255,0,.4); }
}

/* ACTION BAR */
#action-bar {
  display: flex; justify-content: center; gap: 12px; padding: 6px;
  position: relative; z-index: 5;
}
.action-btn {
  padding: 12px 28px; font-size: 15px; background: #3a3520; border: 2px solid #665;
  color: #e0d6c2; border-radius: 6px; cursor: pointer; font-family: inherit;
  transition: all .2s;
}
.action-btn:hover { background: #554a30; border-color: #ff6b35; }
.action-btn.sacrifice { background: #2a3520; border-color: #4a5; color: #8d8; }
.action-btn.sacrifice:hover { background: #3a4530; border-color: #6c6; color: #afa; }

/* ACTION LOG - collapsed by default */
#log-toggle {
  position: fixed; bottom: 140px; right: 12px; z-index: 31;
  cursor: pointer; font-size: 13px; color: #887;
  background: rgba(0,0,0,.4); padding: 4px 10px; border-radius: 4px;
  border: 1px solid #443;
}
#log-toggle:hover { color: #fff; border-color: #ff6b35; }

#action-log {
  position: fixed; bottom: 166px; right: 12px; width: 260px; max-height: 180px;
  overflow-y: auto; font-size: 11px; color: #998; background: rgba(0,0,0,.5);
  border-radius: 6px; padding: 8px;
  scrollbar-width: thin; scrollbar-color: #444 transparent;
  transition: max-height .3s, opacity .3s, padding .3s;
  z-index: 30;
}
#action-log.collapsed {
  max-height: 0; opacity: 0; padding: 0 8px; overflow: hidden; pointer-events: none;
}
#action-log .log-entry { padding: 2px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
#action-log .log-entry:last-child { border: none; }
.log-important { color: #ff6b35 !important; font-weight: bold; }
.log-damage { color: #f44 !important; }
.log-heal { color: #4f4 !important; }
.log-separator {
  border: none !important; border-top: 1px solid #554 !important;
  margin: 4px 0; padding: 0 !important; height: 0;
  color: #665 !important; font-size: 10px !important; text-align: center;
}

/* CARD TOOLTIP */
#card-tooltip {
  position: fixed; z-index: 60; pointer-events: none;
  background: rgba(20,20,10,.95); border: 1px solid #665; border-radius: 6px;
  padding: 8px 12px; font-size: 12px; color: #e0d6c2; max-width: 240px;
  line-height: 1.5; box-shadow: 0 4px 12px rgba(0,0,0,.5);
}

/* MODALS */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex;
  align-items: center; justify-content: center; z-index: 50;
}
.modal-content {
  background: #2a2a1a; border: 2px solid #665; border-radius: 12px;
  padding: 30px; text-align: center; max-width: 440px; width: 90%;
  transition: border-color .3s;
}
.modal-content.attack-flash {
  animation: attackBorderFlash .5s ease-out;
}
@keyframes attackBorderFlash {
  0% { border-color: #f00; box-shadow: 0 0 30px rgba(255,0,0,.5); }
  100% { border-color: #665; box-shadow: none; }
}
.modal-content h2 { color: #ff6b35; margin-bottom: 12px; font-size: 24px; }
.modal-content p { color: #a09880; margin-bottom: 16px; }
.bp-choice {
  display: block; width: 100%; padding: 14px; margin: 8px 0; background: #3a3520;
  border: 2px solid #554; color: #e0d6c2; border-radius: 6px; cursor: pointer;
  font-size: 15px; font-family: inherit; transition: all .15s;
}
.bp-choice:hover { border-color: #ff6b35; background: #4a4530; }
#response-cards { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 12px 0; }
#response-cards .card { cursor: pointer; }
#response-cards .card:hover { transform: translateY(-8px); box-shadow: 0 6px 15px rgba(255,200,0,.4); }

#gameover-title { font-size: 32px; }
#gameover-stats { text-align: left; margin: 16px 0; line-height: 1.8; color: #a09880; }

/* BREAKPOINT ANIMATION */
.breakpoint-flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 98;
  background: radial-gradient(circle, rgba(255,107,53,.4) 0%, transparent 70%);
  animation: bpFlash .8s forwards;
}
@keyframes bpFlash { 0% { opacity: 1; } 100% { opacity: 0; } }

.breakpoint-text {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  font-size: 48px; color: #ff6b35; font-weight: bold; letter-spacing: 6px;
  text-shadow: 0 0 30px rgba(255,107,53,.8); z-index: 99; pointer-events: none;
  animation: bpText 1.2s forwards;
}
@keyframes bpText {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(.5); }
  30% { opacity: 1; transform: translate(-50%,-50%) scale(1.2); }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(1.5) translateY(-30px); }
}

/* OVERCHARGE EXPLOSION */
.overcharge-boom {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: 200px; height: 200px; border-radius: 50%; pointer-events: none; z-index: 98;
  background: radial-gradient(circle, rgba(255,50,0,.8), transparent);
  animation: boom .8s forwards;
}
@keyframes boom {
  0% { opacity: 1; transform: translate(-50%,-50%) scale(.2); }
  50% { opacity: .8; transform: translate(-50%,-50%) scale(2); }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(3); }
}

/* MOMENTUM GLOW */
.momentum-active { animation: momentumPulse 1.5s infinite; }
@keyframes momentumPulse {
  0%, 100% { text-shadow: 0 0 5px #ff6; }
  50% { text-shadow: 0 0 20px #ff6, 0 0 40px #fa0; }
}

/* MOBILE */
@media (max-width: 600px) {
  .card { width: 56px; height: 80px; }
  .card .card-value { font-size: 15px; }
  .card .card-suit { font-size: 18px; }
  .card .card-corner { font-size: 8px; }
  .charge-pile .card { width: 40px; height: 56px; margin-top: -40px; }
  .charge-pile .card .card-suit { font-size: 13px; }
  .charge-pile .card .card-value { font-size: 11px; }
  .played-slot { width: 56px; height: 80px; }
  .action-btn { padding: 14px 32px; font-size: 16px; min-height: 48px; }
  .bp-choice { padding: 16px; font-size: 16px; min-height: 48px; }
  #response-skip { padding: 14px 32px; font-size: 16px; min-height: 48px; }
  #response-cards .card { width: 60px; height: 84px; }
  #player-hand, #opponent-hand { min-height: 90px; }
  #action-log { width: 200px; font-size: 10px; }
  #top-bar { padding: 6px 8px; gap: 8px; }
  .hp-bar-container { height: 24px; }
  .hp-bar { font-size: 12px; }
  .title { font-size: 36px; }
}

/* Royal Combo animation */
.royal-flash {
  background: radial-gradient(circle, rgba(255,215,0,0.6) 0%, transparent 70%) !important;
}
.royal-text {
  color: #ffd700 !important;
  text-shadow: 0 0 20px #ffd700, 0 0 40px #ff8c00 !important;
}

/* Suit streak flash */
.suit-streak-flash {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 9998;
  animation: suitFlash 0.6s ease-out forwards;
}
@keyframes suitFlash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}
