/* ==========================================================================
   ONE SHOT - MAIN STYLES & DESIGN SYSTEM
   Mobile-first, zero-scroll viewport architecture with responsive desktop cards
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  /* System Dark Palette */
  --bg-app: #08090c;
  --bg-primary: #08090c;
  --bg-secondary: #12141a;
  --bg-tertiary: #181b22;
  --bg-card: #12141a;
  --bg-surface: #181b22;
  --bg-elevated: #222631;
  --border-subtle: #272b38;
  --border-medium: #374151;
  --border-bold: #3d4356;
  
  --text-primary: #ffffff;
  --text-secondary: #9da7be;
  --text-muted: #626b82;

  /* Clue Feedback Colors */
  --color-green: #10b981;
  --color-green-glow: rgba(16, 185, 129, 0.4);
  --color-yellow: #f59e0b;
  --color-yellow-glow: rgba(245, 158, 11, 0.4);
  --color-grey: #374151;
  --color-grey-dark: #1f2937;
  --color-empty: #181b22;
  
  --color-error-glow: rgba(239, 68, 68, 0.45);
  --color-success: #10b981;
  /* Layout Tokens - Dynamic Viewport Budget (Header ~5%, Tabs ~5%, Board ~50%, Keyboard ~22%) */
  --header-height: clamp(36px, 5.5vh, 48px);
  --tabs-height: clamp(32px, 5vh, 42px);
  --board-max-width: min(560px, 94vw);
  /* Dynamic Adaptive Tile Sizing based on Clue Row Count */
  --tile-size: min(
    calc((50vh - 20px) / 4.8),
    calc((min(var(--board-max-width), 94vw) - 36px) / 5),
    68px
  );
  
  --key-gap: clamp(3px, 0.6vh, 6px);
  --key-height: min(
    calc((21vh - 12px) / 3),
    50px
  );

  /* Clue Palette */
  --color-green: #10b981;
  --color-green-glow: transparent;
  --color-yellow: #f59e0b;
  --color-yellow-glow: transparent;
  --color-grey: #3f3f46;
  --color-grey-dark: #272729;

  --border-radius-tile: 3px;
  --border-radius-sm: 4px;
  --border-radius-md: 7px;
  --border-radius-lg: 12px;
  --border-radius-full: 9999px;

  /* Animations */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 350ms cubic-bezier(0.16, 1, 0.3, 1);
/* Reset & Base Setup */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-app, #08090c);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* App Container Layout - Full Screen Budget */
.app-container {
  width: 100%;
  max-width: var(--board-max-width);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: clamp(6px, 1.4vh, 14px) clamp(8px, 2vw, 16px);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

/* 1. Header with 3-Column Zero-Overlap Layout */
.app-header {
  width: 100%;
  height: var(--header-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: clamp(4px, 0.8vh, 8px);
  gap: 4px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: clamp(3px, 0.8vw, 6px);
  flex-shrink: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: clamp(3px, 0.8vw, 6px);
  flex-shrink: 0;
}

.brand-title {
  flex: 1;
  text-align: center;
  font-size: clamp(12px, 3.2vw, 17px);
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 4px;
  transition: text-shadow 0.25s ease-out;
}

.brand-title:hover {
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.7), 0 0 2px #ffffff;
}

.icon-button {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: clamp(28px, 3.8vh, 32px);
  height: clamp(28px, 3.8vh, 32px);
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.icon-button:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.icon-button:active {
  transform: translateY(0);
}

/* 2. Daily Navigation Tabs */
.daily-tabs-wrapper {
  width: 100%;
  height: var(--tabs-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-lg);
  padding: 3px;
  margin-bottom: clamp(4px, 0.8vh, 10px);
  gap: 6px;
}

.daily-tab {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--border-radius-md);
  color: var(--text-secondary);
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.daily-tab:hover:not(.locked) {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.daily-tab.active {
  border-color: var(--border-medium);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.daily-tab.locked {
  opacity: 0.35;
  cursor: not-allowed;
}

.tab-title {
  font-size: clamp(10px, 1.6vh, 12px);
  font-weight: 800;
  letter-spacing: 0.5px;
  z-index: 2;
}

/* Color Highlight / Progress Track on Bottom of Each Tab */
.tab-progress-track {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  margin-top: 2px;
  overflow: hidden;
  position: relative;
  z-index: 2;
}

.tab-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  transition: width 0.3s ease, background 0.3s ease;
}

.header-date-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  width: auto !important;
  padding: 0 6px;
}

.header-date-text {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
}

@media (max-width: 440px) {
  .header-date-text {
    display: none;
  }
  .header-date-btn {
    width: clamp(28px, 3.8vh, 32px) !important;
    padding: 0;
    justify-content: center;
  }
  .header-rating-label {
    display: none;
  }
}

.header-rating-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-md);
  padding: clamp(3px, 0.6vh, 5px) clamp(5px, 1vw, 8px);
  user-select: none;
}

.header-rating-label {
  font-size: 9px;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.header-rating-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(11px, 1.8vh, 13px);
  font-weight: 800;
  color: #f59e0b;
}

/* Board Top Status Pill */
.board-top-status {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: clamp(3px, 0.8vh, 6px);
  flex-shrink: 0;
}

/* ==========================================================================
   SEGMENTED TIME DECAY TIMER BAR
   ========================================================================== */
.timer-bar-wrapper {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: clamp(2px, 0.5dvh, 6px);
}

.timer-bar-container {
  flex: 1;
  height: clamp(6px, 1.1dvh, 8px);
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--bg-secondary);
  padding: 1px 3px;
  border-radius: 5px;
  border: 1px solid var(--border-subtle);
}

.timer-bonus-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(10px, 1.6vmin, 11.5px);
  font-weight: 800;
  color: #10b981;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 4px;
  padding: 1px 5px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  line-height: 1;
  animation: pulseGlow 1.5s infinite alternate;
}

@keyframes pulseGlow {
  0% { opacity: 0.85; transform: scale(1); }
  100% { opacity: 1; transform: scale(1.04); }
}

.timer-grace-track {
  height: 100%;
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.timer-grace-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #10b981, #34d399);
  border-radius: 3px;
  transition: width 0.1s linear;
}

.timer-elo-track {
  height: 100%;
  position: relative;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  align-items: center;
}

.timer-elo-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 100%;
  background: #10b981;
  border-radius: 3px;
  transition: width 0.1s linear;
}

.timer-ticks-container {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 2px;
  pointer-events: none;
  z-index: 2;
}

.timer-tick-block {
  flex: 1;
  height: 100%;
  border-right: 1px solid rgba(22, 23, 29, 0.7);
  opacity: 0.9;
}

.timer-tick-block:last-child {
  border-right: none;
}

.player-rating-display {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-tertiary);
  padding: 4px 10px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-subtle);
}

.rating-label {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.rating-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 800;
  color: #f59e0b;
}

.stakes-display {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stake-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.2px;
}

.stake-pill.win {
  color: #34d399;
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.35);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.15);
}

.stake-pill.loss {
  color: #f87171;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.35);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.15);
}

/* Bottom Actions Bar (Give Up) */
.game-bottom-actions {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1px 0 clamp(1px, 0.4dvh, 3px) 0;
}

.clue-market-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin: clamp(6px, 1.2vh, 12px) 0;
  flex-shrink: 0;
}

.clue-market-btn {
  width: calc(var(--tile-size) * 5 + var(--tile-gap) * 4);
  height: calc(var(--tile-size) * 0.72);
  min-height: 24px;
  background: var(--bg-secondary);
  border: 1px dashed var(--border-medium);
  border-radius: var(--border-radius-tile, 3px);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: calc(var(--tile-size) * 0.26);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  letter-spacing: 0.02em;
}

.clue-market-btn:hover:not(:disabled) {
  background: var(--bg-tertiary);
  border-color: #a1a1aa;
  border-style: solid;
  color: #ffffff;
  transform: translateY(-1px);
}

.clue-market-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.heart-icon.pulse-loss {
  animation: heartBreak 0.5s ease;
}

@keyframes heartBreak {
  0% { transform: scale(1.3); color: #ff0000; filter: drop-shadow(0 0 12px red); }
  50% { transform: scale(0.7) rotate(-15deg); }
  100% { transform: scale(0.85) rotate(0); color: #3f3f46; }
}

/* Hard Error Toast */
.error-toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: #ef4444;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: var(--border-radius-full);
  box-shadow: 0 10px 25px rgba(239, 68, 68, 0.4);
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-normal);
  z-index: 100;
}

.error-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 4. Footer Copyright */
.app-footer {
  height: clamp(12px, 2vh, 18px);
  flex-shrink: 0;
  margin-top: 0;
  padding: 0;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  opacity: 0.7;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  justify-content: center;
}
