/* ==========================================================================
   Base & Root Variables
   ========================================================================== */
:root {
  --bg-color: #121214;
  --panel-bg: #1e1e24;
  --border-color: #2d2d34;
  
  --text-primary: #f0f0f5;
  --text-secondary: #a0a0b0;
  --text-muted: #6e6e7d;
  
  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  
  --color-success: #10b981;
  --color-success-hover: #059669;
  
  --color-danger: #ef4444;
  
  --color-warning: #f97316; /* Hot glow orange */
  --color-warning-light: #ffedd5;
  
  --font-title: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  --board-size: 380px;
  --border-radius-sm: 8px;
  --border-radius-md: 16px;
  --border-radius-lg: 24px;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.4);
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and Global Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
}

/* App Container Layout */
#app {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* ==========================================================================
   Header Styling
   ========================================================================== */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 16px;
}

.logo {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 26px;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.logo span {
  color: var(--color-primary);
}

.header-right {
  display: flex;
  gap: 8px;
}

.header-right button {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: var(--border-radius-sm);
  width: 38px;
  height: 38px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.header-right button:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.icon {
  width: 18px;
  height: 18px;
}

/* ==========================================================================
   Difficulty Navigation Tabs
   ========================================================================== */
.difficulty-tabs {
  display: flex;
  gap: 6px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 4px;
  margin-bottom: 24px;
}

.tab-item {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 14px;
  padding: 8px 0;
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.tab-item:hover {
  color: var(--text-primary);
}

.tab-item.active {
  background: var(--panel-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Board & Image Elements
   ========================================================================== */
.game-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.board-wrapper {
  width: 100%;
  max-width: var(--board-size);
  aspect-ratio: 1 / 1;
  margin-bottom: 20px;
}

.game-board {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: var(--border-radius-md);
  overflow: hidden;
  background-color: #0c0c0e;
  border: 2px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  user-select: none;
}

#blurred-bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#revealed-tiles-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.revealed-tile {
  position: absolute;
  object-fit: cover;
  pointer-events: none;
  opacity: 0;
  animation: reveal-tile 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.15) forwards;
}

#grid-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: grid;
  pointer-events: none;
}

.grid-cell {
  border: 0.5px solid rgba(255, 255, 255, 0.08);
}

/* ==========================================================================
   HUD Stats Indicator
   ========================================================================== */
.hud-container {
  display: flex;
  width: 100%;
  max-width: var(--board-size);
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  padding: 10px 16px;
  border-radius: var(--border-radius-md);
}

.hud-item {
  display: flex;
  flex-direction: column;
}

.hud-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.8px;
  margin-bottom: 2px;
}

.hud-value {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 700;
}

.history-badge {
  background: rgba(249, 115, 22, 0.1);
  border: 1px solid rgba(249, 115, 22, 0.3);
  color: var(--color-warning);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 10px;
}

/* ==========================================================================
   Input / Controls / Badges
   ========================================================================== */
.controls-container {
  width: 100%;
  max-width: var(--board-size);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.feedback-badge {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
  text-align: center;
  transition: var(--transition-fast);
}

.feedback-badge.hot {
  background: rgba(249, 115, 22, 0.15);
  border: 1px solid var(--color-warning);
  color: #ffedd5;
  box-shadow: 0 0 10px rgba(249, 115, 22, 0.2);
}

.feedback-badge.cold {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--color-danger);
  color: #fee2e2;
}

.guess-form {
  display: flex;
  width: 100%;
  gap: 8px;
}

#guess-input {
  flex: 1;
  background-color: var(--panel-bg);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--border-radius-sm);
  padding: 12px 16px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  outline: none;
  transition: var(--transition-fast);
}

#guess-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

#guess-input.glow-hot {
  animation: hot-glow 1.5s infinite ease-in-out;
}

.submit-btn {
  background-color: var(--color-primary);
  color: white;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  border: none;
  border-radius: var(--border-radius-sm);
  padding: 0 20px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.submit-btn:hover {
  background-color: var(--color-primary-hover);
}

.submit-btn:disabled {
  background-color: var(--border-color);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ==========================================================================
   Modals & Overlays
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 1;
  transition: opacity var(--transition-fast);
}

.modal-content {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  width: 90%;
  max-width: 440px;
  border-radius: var(--border-radius-md);
  padding: 28px;
  box-shadow: var(--shadow-lg);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.close-modal-btn {
  position: absolute;
  top: 16px;
  right: 18px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.close-modal-btn:hover {
  color: var(--text-primary);
}

h2 {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 22px;
  margin-bottom: 18px;
}

h3 {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 16px;
  margin: 16px 0 8px 0;
}

p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 12px;
}

ul {
  margin-left: 18px;
  margin-bottom: 16px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

li {
  margin-bottom: 6px;
}

.btn {
  display: block;
  width: 100%;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  padding: 12px 16px;
  border: none;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  text-align: center;
  transition: var(--transition-fast);
  margin-top: 16px;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--color-primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
}

.btn-success {
  background-color: var(--color-success);
  color: white;
}

.btn-success:hover {
  background-color: var(--color-success-hover);
}

/* Win/Loss Stats styling */
.win-loss-banner {
  text-align: center;
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 700;
  padding: 10px;
  border-radius: var(--border-radius-sm);
  margin-bottom: 16px;
}

.win-loss-banner.win {
  background: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
  border: 1px solid var(--color-success);
}

.win-loss-banner.loss {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
}

.stats-grid {
  display: flex;
  justify-content: space-between;
  margin-bottom: 24px;
}

.stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.stat-number {
  font-family: var(--font-title);
  font-size: 26px;
  font-weight: 700;
}

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
  text-align: center;
}

/* Solution Box */
.solution-section {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 12px;
  margin-bottom: 18px;
  text-align: center;
}

.solution-image-container {
  width: 100%;
  max-height: 160px;
  overflow: hidden;
  border-radius: 4px;
  margin-top: 8px;
  border: 1px solid var(--border-color);
}

#solution-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.copy-success {
  color: var(--color-success);
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  margin-top: 8px;
}

/* History List style */
.history-intro {
  margin-bottom: 16px;
}

.loading {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 20px 0;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 4px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: var(--border-radius-sm);
  transition: var(--transition-fast);
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.history-date {
  font-size: 14px;
  font-weight: 500;
}

.history-mode {
  background: rgba(59, 130, 246, 0.1);
  color: var(--color-primary);
  border: 1px solid rgba(59, 130, 246, 0.2);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
}

.history-play-btn {
  background: var(--color-primary);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.history-play-btn:hover {
  background: var(--color-primary-hover);
}

/* ==========================================================================
   Animations Helper Classes
   ========================================================================== */
.hidden {
  display: none !important;
}

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

.shake {
  animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes hot-glow {
  0%, 100% { 
    border-color: var(--color-warning); 
    box-shadow: 0 0 4px rgba(249, 115, 22, 0.3);
  }
  50% { 
    border-color: #fdba74; 
    box-shadow: 0 0 14px rgba(249, 115, 22, 0.6);
  }
}

@keyframes reveal-tile {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.app-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  margin-top: 16px;
}

/* ==========================================================================
   Guess History List Styles
   ========================================================================== */
.guess-history-section {
  width: 100%;
  max-width: var(--board-size);
  margin-top: 20px;
  margin-bottom: 20px;
}

.guess-history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  align-items: center;
}

.guess-tag {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 16px;
  transition: var(--transition-fast);
}

.guess-tag.cold {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.guess-tag.hot {
  background: rgba(249, 115, 22, 0.15);
  color: #fdba74;
  border: 1px solid rgba(249, 115, 22, 0.35);
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.1);
}

/* ==========================================================================
   Next Modes recommendation section
   ========================================================================== */
.next-modes-section {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px dashed var(--border-color);
  text-align: center;
}

.next-modes-section h3 {
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.next-modes-section p {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.next-modes-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.next-modes-buttons .btn {
  width: auto;
  min-width: 100px;
  flex: 1 1 auto;
  margin-top: 0;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--border-radius-sm);
  transition: var(--transition-fast);
  cursor: pointer;
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* Share Actions Layout */
.share-buttons-container {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.share-buttons-container .btn {
  flex: 1;
  margin-top: 0;
  min-width: 120px;
}
