@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  --bg-gradient: radial-gradient(circle at 50% 0%, #152038 0%, #090e17 75%, #05080f 100%);
  --card-bg: rgba(18, 26, 43, 0.85);
  --card-border: rgba(212, 175, 55, 0.3);
  --card-border-glow: rgba(212, 175, 55, 0.15);
  --gold-primary: #f59e0b;
  --gold-light: #fbbf24;
  --gold-metallic: #d4af37;
  --gold-shadow: rgba(245, 158, 11, 0.25);
  --text-main: #f8f1e5;
  --text-muted: #94a3b8;
  --accent-color: #ef4444;
  --hp-color: #f43f5e;
  --hg-color: #f97316;
  --ration-color: #10b981;
  --disabled-color: #334155;
}

body[data-mode="work"] {
  --accent-color: #ef4444;
  --mode-glow: rgba(239, 68, 68, 0.25);
}

body[data-mode="hunt"] {
  --accent-color: #10b981;
  --mode-glow: rgba(16, 185, 129, 0.25);
}

body[data-mode="shortBreak"] {
  --accent-color: #3b82f6;
  --mode-glow: rgba(59, 130, 246, 0.25);
}

body[data-mode="longBreak"] {
  --accent-color: #8b5cf6;
  --mode-glow: rgba(139, 92, 246, 0.25);
}

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

body {
  background: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  transition: background 0.5s ease;
}

h1, h2, h3, .level-badge, .gold-badge, .clock-display, .time-display {
  font-family: 'Cinzel', serif;
}

.app-container {
  width: 100%;
  max-width: 920px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  padding: 16px 24px;
  border-radius: 18px;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), inset 0 0 15px var(--card-border-glow);
}

.title-wrapper h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 0.5px;
  text-shadow: 0 2px 10px rgba(245, 158, 11, 0.3);
  display: flex;
  align-items: center;
  gap: 10px;
}

.title-wrapper .subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
}

.action-icon-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 2px 4px;
  border-radius: 6px;
  transition: transform 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
  user-select: none;
  line-height: 1;
}

.action-icon-btn:hover {
  transform: scale(1.15);
}

.action-icon-btn.muted {
  opacity: 0.6;
  filter: grayscale(0.5);
}

#gear-trigger {
  cursor: pointer;
  display: inline-block;
  user-select: none;
  font-size: 1.3rem;
  transition: transform 0.2s ease, filter 0.2s ease;
}

#gear-trigger.holding {
  animation: gearHoldPulse 4s linear forwards;
}

@keyframes gearHoldPulse {
  0% { transform: scale(1) rotate(0deg); filter: drop-shadow(0 0 0px var(--gold-light)); }
  50% { transform: scale(1.25) rotate(180deg); filter: drop-shadow(0 0 8px var(--gold-primary)); }
  100% { transform: scale(1.4) rotate(360deg); filter: drop-shadow(0 0 16px var(--gold-light)); }
}

.clock-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.clock-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gold-metallic);
}

.clock-display {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: 1px;
}

.banner {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 0.88rem;
  text-align: center;
  font-weight: 600;
  display: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.banner.visible {
  display: block;
}

.banner-danger {
  background: rgba(220, 38, 38, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}

.banner-warning {
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: var(--gold-light);
}

.app-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 820px) {
  .app-grid {
    grid-template-columns: 1.1fr 0.9fr;
  }
}

.timer-column, .side-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

.timer-card, .settings-card, .gamification-card, .downtime-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(12px);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), inset 0 0 12px var(--card-border-glow);
}

.timer-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.mode-selector {
  display: flex;
  background: rgba(9, 14, 23, 0.6);
  padding: 5px;
  border-radius: 14px;
  border: 1px solid rgba(212, 175, 55, 0.15);
  gap: 4px;
  overflow-x: auto;
  width: 100%;
}

.mode-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 10px 8px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
}

.mode-btn.active {
  background: var(--accent-color);
  color: #ffffff;
  box-shadow: 0 2px 12px var(--mode-glow);
}

.mode-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.yield-display-row {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.timer-display-container {
  position: relative;
  width: 240px;
  height: 240px;
  margin: 20px auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

.progress-ring {
  position: absolute;
  top: 0;
  left: 0;
  transform: rotate(-90deg);
}

.progress-ring__circle {
  transition: stroke-dashoffset 0.3s linear, stroke 0.4s ease;
  stroke: var(--accent-color);
  filter: drop-shadow(0 0 6px var(--mode-glow));
}

.time-display {
  font-size: 3.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
  color: var(--text-main);
  text-shadow: 0 0 15px rgba(248, 241, 229, 0.2);
}

.controls {
  display: flex;
  gap: 12px;
}

.control-btn {
  flex: 1;
  padding: 14px 20px;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: 'Cinzel', serif;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: transform 0.1s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.control-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.control-btn.primary {
  background: linear-gradient(135deg, var(--gold-primary) 0%, #d97706 100%);
  color: #090e17;
  border-color: var(--gold-light);
  box-shadow: 0 4px 16px var(--gold-shadow);
}

.control-btn.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold-primary) 100%);
}

.control-btn.secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.control-btn.secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
}

.control-btn:disabled {
  background: var(--disabled-color);
  border-color: transparent;
  color: rgba(255, 255, 255, 0.3);
  cursor: not-allowed;
  box-shadow: none;
}

.card-title {
  font-size: 0.95rem;
  margin-bottom: 16px;
  color: var(--gold-light);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.yield-badge {
  font-size: 0.75rem;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid var(--gold-metallic);
  color: var(--gold-light);
  padding: 4px 12px;
  border-radius: 14px;
  text-transform: none;
  letter-spacing: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 600;
}

.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.level-badge {
  background: linear-gradient(135deg, var(--gold-metallic) 0%, var(--gold-primary) 100%);
  color: #090e17;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 8px var(--gold-shadow);
}

.gold-badge {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid var(--gold-metallic);
  color: var(--gold-light);
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.survival-metrics {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.metric-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.stat-val-hp { color: var(--hp-color); }
.stat-val-hg { color: var(--hg-color); }
.stat-val-rations { color: var(--ration-color); }

.meter-bar-container {
  width: 100%;
  height: 8px;
  background: rgba(9, 14, 23, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

.meter-bar-fill {
  height: 100%;
  width: 0%;
  transition: width 0.4s ease;
}

.meter-hp { background: linear-gradient(90deg, #e11d48, var(--hp-color)); }
.meter-hg { background: linear-gradient(90deg, #ea580c, var(--hg-color)); }

.xp-counter-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.xp-counter {
  color: var(--gold-light);
  font-weight: 600;
}

.xp-bar-container {
  width: 100%;
  height: 8px;
  background: rgba(9, 14, 23, 0.8);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
}

.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-metallic) 0%, var(--gold-light) 100%);
  width: 0%;
  transition: width 0.4s ease;
  box-shadow: 0 0 8px var(--gold-primary);
}

.xp-hint {
  font-size: 0.73rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-subtitle {
  font-size: 0.88rem;
  color: var(--gold-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-item label {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.setting-item .limit-info {
  font-size: 0.65rem;
  color: var(--gold-metallic);
}

.setting-item input {
  background: rgba(9, 14, 23, 0.6);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  color: var(--text-main);
  padding: 10px;
  font-size: 0.95rem;
  text-align: center;
  width: 100%;
  font-weight: 600;
}

.setting-item input:focus {
  outline: none;
  border-color: var(--gold-light);
  box-shadow: 0 0 8px var(--gold-shadow);
}

/* Audio Settings Toggle Controls */
.audio-settings-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(9, 14, 23, 0.5);
  border: 1px solid rgba(212, 175, 55, 0.15);
  border-radius: 12px;
  padding: 12px 14px;
}

.toggle-setting {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.toggle-setting input[type="checkbox"] {
  accent-color: var(--gold-primary);
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.toggle-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toggle-label strong {
  font-size: 0.85rem;
  color: var(--text-main);
}

.toggle-label small {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Downtime Shop & Market Styles */
.downtime-card.market-locked {
  opacity: 0.5;
  filter: grayscale(0.6);
  pointer-events: none;
  position: relative;
}

.shop-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 12px;
}

.shop-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(9, 14, 23, 0.6);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 14px;
  padding: 16px;
  gap: 16px;
}

.shop-item-details {
  display: flex;
  align-items: center;
  gap: 14px;
}

.shop-item-icon {
  font-size: 2rem;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid var(--gold-metallic);
  padding: 8px 12px;
  border-radius: 12px;
}

.shop-item-info h3 {
  font-size: 1rem;
  color: var(--gold-light);
  margin-bottom: 2px;
}

.shop-item-info p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.shop-item-price {
  font-size: 0.85rem;
  color: var(--gold-primary);
  font-weight: 700;
  margin-top: 4px;
}

.buy-btn {
  padding: 10px 16px;
  border: 1px solid var(--gold-light);
  background: linear-gradient(135deg, var(--gold-primary) 0%, #d97706 100%);
  color: #090e17;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.buy-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold-primary) 100%);
  box-shadow: 0 2px 10px var(--gold-shadow);
}

.buy-btn:disabled {
  background: var(--disabled-color);
  border-color: transparent;
  color: rgba(255, 255, 255, 0.3);
  cursor: not-allowed;
}

/* MODAL OVERLAYS (SETTINGS & DEBUG) */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(5, 8, 15, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  padding: 20px;
}

.modal-card {
  background: #0d1527;
  border: 1px solid var(--gold-metallic);
  border-radius: 20px;
  padding: 24px;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), inset 0 0 15px var(--gold-shadow);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.2);
  padding-bottom: 12px;
}

.modal-header h2 {
  font-size: 1.1rem;
  color: var(--gold-light);
  display: flex;
  align-items: center;
  gap: 8px;
}

.close-modal-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

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

.debug-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.debug-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(18, 26, 43, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 14px;
  border-radius: 12px;
  gap: 12px;
}

.debug-row.danger-row {
  background: rgba(220, 38, 38, 0.1);
  border-color: rgba(239, 68, 68, 0.4);
}

.debug-row-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 110px;
}

.debug-btn-group {
  display: flex;
  gap: 6px;
}

.debug-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.debug-btn:hover {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--gold-metallic);
  color: var(--gold-light);
}

.debug-btn.reset-danger-btn {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  color: #fca5a5;
}

.debug-btn.reset-danger-btn:hover {
  background: rgba(239, 68, 68, 0.4);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}