/* Matgo Premium Styling (style.css) */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;700;900&family=Outfit:wght@300;400;700;900&display=swap');

:root {
  --bg-board: linear-gradient(135deg, #0e2716 0%, #07150c 100%);
  --bg-panel: rgba(18, 30, 22, 0.7);
  --border-gold: rgba(212, 175, 55, 0.4);
  --text-primary: #f5f5f5;
  --text-gold: #ffd700;
  --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --card-width: 80px;
  --card-height: 133px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Noto Sans KR', 'Outfit', sans-serif;
  user-select: none;
}

body {
  background: var(--bg-board);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* App Header */
header {
  background: rgba(0, 0, 0, 0.5);
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-gold);
  z-index: 10;
}

header h1 {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--text-gold);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.subtitle {
  font-size: 10px;
  color: #888;
  margin-left: 8px;
}

/* Game Table Layout */
#game-container {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 300px;
  height: calc(100vh - 50px);
  overflow: hidden;
}

#table-area {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 15px;
  position: relative;
}

/* Zones: AI, Floor, Player */
.play-zone {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.zone-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #ccc;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 4px;
}

.score-badge {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-gold);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 11px;
  color: var(--text-gold);
}

.cards-container {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  min-height: calc(var(--card-height) + 10px);
  align-items: center;
  padding: 5px 0;
  overflow-x: auto;
}

/* Collected/Piles Area */
.collected-area {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  background: rgba(0, 0, 0, 0.1);
  padding: 5px;
  border-radius: 8px;
}

.collected-type-group {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  min-height: 48px;
}

.type-label {
  font-size: 10px;
  color: #aaa;
  display: flex;
  justify-content: space-between;
  margin-bottom: 3px;
  font-weight: bold;
}

.type-label span {
  color: var(--text-gold);
}

.collected-cards-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

/* Floor (Middle Zone) */
#floor-zone {
  flex: 1;
  margin: 10px 0;
  display: flex;
  align-items: center;
  gap: 15px;
  background: rgba(255, 255, 255, 0.01);
  border-radius: 16px;
  padding: 10px;
  min-height: 310px;
}

#floor-cards {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  align-content: center;
  max-height: 100%;
  overflow-y: auto;
}

.floor-month-group {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  min-height: var(--card-height);
  padding: 4px;
  display: flex;
  flex-direction: row;
  gap: 2px;
  position: relative;
  justify-content: center;
  align-items: center;
  border: 1px dashed rgba(212, 175, 55, 0.08);
  min-width: calc(var(--card-width) + 12px);
  transition: background-color 0.2s;
}

.empty-slot-placeholder {
  width: var(--card-width);
  height: var(--card-height);
  border: 1.5px dashed rgba(212, 175, 55, 0.12);
  border-radius: 4px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: rgba(255, 255, 255, 0.15);
  font-size: 11px;
  font-weight: bold;
}

/* Flying card animation container */
.flying-card {
  pointer-events: none;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.6);
  z-index: 9999;
}

/* Slap hitting impact effect */
.slap-impact {
  position: fixed;
  width: 80px;
  height: 80px;
  border: 4px solid var(--text-gold);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.1);
  opacity: 1;
  pointer-events: none;
  z-index: 10000;
  animation: slapRing 0.4s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

@keyframes slapRing {
  0% {
    transform: translate(-50%, -50%) scale(0.1);
    opacity: 1;
    border-color: #ffd700;
  }
  50% {
    opacity: 0.8;
    border-color: #ff5722;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.5);
    opacity: 0;
    border-color: #f44336;
  }
}


#deck-area {
  width: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

#deck-stack {
  width: var(--card-width);
  height: var(--card-height);
  position: relative;
}

.empty-deck-txt {
  width: var(--card-width);
  height: var(--card-height);
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 12px;
  color: #666;
}

/* Card Visual Styles */
.hwatu-card {
  width: var(--card-width);
  height: var(--card-height);
  border-radius: 6px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s, margin-right 0.2s, box-shadow 0.2s;
  cursor: default;
  position: relative;
  background: #FFFDF9;
  flex-shrink: 0;
}

.card-back {
  background: #800C13;
}

.selectable {
  cursor: pointer;
}

.selectable:hover {
  transform: translateY(-15px) scale(1.05);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.6), 0 0 12px rgba(255, 215, 0, 0.5);
  z-index: 100 !important;
}

/* User & AI hand overlap styles */
#user-hand {
  display: flex;
  flex-wrap: nowrap;
  padding-right: 50px;
}

#user-hand .hwatu-card {
  margin-right: -48px; /* 80px width: overlap 48px -> 32px (40%) visible */
}

#user-hand .hwatu-card:last-child {
  margin-right: 0;
}

#user-hand .hwatu-card:hover {
  margin-right: -24px; /* Expands spacing slightly on hover for readability */
}

#ai-hand {
  display: flex;
  flex-wrap: nowrap;
  padding-right: 50px;
}

#ai-hand .hwatu-card {
  margin-right: -56px; /* 80px width: overlap 56px -> 24px (30%) visible (at least 1/4) */
}

#ai-hand .hwatu-card:last-child {
  margin-right: 0;
}

.match-highlight {
  box-shadow: 0 0 12px #ef5350, 0 0 0 2px #ef5350;
  cursor: pointer;
  z-index: 100 !important;
}

.selectable-deck {
  cursor: pointer;
  box-shadow: 0 0 10px rgba(0, 230, 118, 0.5), 0 0 0 1px #00e676;
}
.selectable-deck:hover {
  transform: scale(1.05);
}

.mini-card {
  width: 20px;
  height: 33px;
  border-radius: 2px;
  box-shadow: 1px 1px 3px rgba(0,0,0,0.3);
}
.mini-card .type-label,
.mini-card text {
  display: none !important;
}
.mini-card circle {
  r: 4 !important;
  cy: 6 !important;
  cx: 15 !important;
}

/* Sidebar Panel */
#sidebar {
  background: var(--bg-panel);
  border-left: 1px solid var(--border-gold);
  display: flex;
  flex-direction: column;
  padding: 15px;
  box-shadow: var(--shadow-premium);
  backdrop-filter: blur(8px);
  z-index: 5;
}

.panel-section {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.panel-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-gold);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Configuration inputs */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 11px;
}

.setting-row select,
.setting-row input[type="checkbox"] {
  background: #111;
  border: 1px solid var(--border-gold);
  color: #fff;
  padding: 2px 5px;
  border-radius: 4px;
}

/* Game Logs */
#game-log-list {
  list-style: none;
  font-size: 11px;
  max-height: 150px;
  overflow-y: auto;
  color: #aaa;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#game-log-list li {
  padding: 2px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

/* Status Banner */
#status-banner {
  background: rgba(0,0,0,0.6);
  padding: 8px 15px;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  max-width: 600px;
  margin: 0 auto;
}

.status-ready { border-color: #ffd700; color: #ffd700; }
.status-user { border-color: #2e7d32; color: #a5d6a7; }
.status-ai { border-color: #c62828; color: #ef9a9a; }
.status-over { border-color: #9e9e9e; color: #e0e0e0; }

.action-toast {
  animation: pulseToast 0.4s ease infinite alternate;
}

@keyframes pulseToast {
  0% { transform: scale(1); box-shadow: 0 0 5px rgba(255, 215, 0, 0.2); }
  100% { transform: scale(1.02); box-shadow: 0 0 15px rgba(255, 215, 0, 0.6); }
}

/* Glassmorphism Modals */
#modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(5px);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  display: none; /* Controlled by JS */
}

.glass-modal {
  background: rgba(20, 35, 25, 0.85);
  border: 2px solid var(--border-gold);
  border-radius: 16px;
  padding: 25px 35px;
  width: 380px;
  text-align: center;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
}

.glass-modal h2 {
  font-size: 24px;
  color: var(--text-gold);
  margin-bottom: 15px;
  font-weight: 900;
}

.glass-modal p {
  font-size: 13px;
  color: #ccc;
  margin-bottom: 20px;
}

.modal-btns {
  display: flex;
  justify-content: center;
  gap: 15px;
}

/* Premium Buttons */
.btn-premium {
  background: linear-gradient(135deg, #d4af37 0%, #aa7c11 100%);
  border: none;
  color: #111;
  padding: 10px 24px;
  font-size: 13px;
  font-weight: 900;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(0,0,0,0.2);
  transition: transform 0.2s, box-shadow 0.2s;
  width: 100%;
}
.btn-premium:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(255, 215, 0, 0.4);
}
.btn-premium:active {
  transform: translateY(0);
}

.btn-secondary {
  background: linear-gradient(135deg, #424242 0%, #212121 100%);
  color: #fff;
}

/* Score Display Details inside GameOver */
.score-details-box {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 20px;
}

.score-details-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12px;
}

.score-details-row:last-child {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 6px;
  font-size: 15px;
  font-weight: bold;
  color: var(--text-gold);
}

.txt-user { color: #81c784; font-weight: bold; }
.txt-ai { color: #e57373; font-weight: bold; }

/* Responsive adjustments */
@media(max-width: 1000px) {
  #game-container {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    height: auto;
    overflow-y: auto;
  }
  #sidebar {
    border-left: none;
    border-top: 1px solid var(--border-gold);
  }
}
