/**
 * Infinity Circles — layout and styles.
 * Two screens: save menu and game screen; only one visible at a time.
 * Game screen uses Visily Idle Odyssey–inspired layout (white, header, resources, ring, pill bar, footer).
 */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #e8ecf2;
  color: #1e293b;
  font-family: system-ui, -apple-system, sans-serif;
}

/* ---- Screens: only one visible ---- */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.screen.active {
  display: flex;
}

/* ---- Save menu ---- */
#save-menu {
  background: #fff;
}

#save-menu h1 {
  margin: 0 0 2rem;
  font-size: 2rem;
  color: #e94560;
}

.slots {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  justify-content: center;
}

.slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.5rem;
  min-width: 180px;
  background: #d5dce8;
  border: 2px solid #94a3b8;
  border-radius: 8px;
}

.slot-label {
  font-weight: 600;
  color: #475569;
}

.slot-status {
  font-size: 0.9rem;
  color: #64748b;
}

.slot-status.has-save {
  color: #4ade80;
}

.slot-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.btn {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: #64748b;
  color: #fff;
}

.btn:hover:not(:disabled) {
  background: #475569;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-play {
  background: #16a34a;
}

.btn-play:hover:not(:disabled) {
  background: #15803d;
}

.btn-new {
  background: #64748b;
}

.btn-menu {
  margin-top: 0.5rem;
  background: #94a3b8;
}

.btn-menu:hover:not(:disabled) {
  background: #64748b;
}

.btn-test {
  font-size: 0.85rem;
  background: #94a3b8;
  color: #1e293b;
}

.btn-test:hover:not(:disabled) {
  background: #64748b;
  color: #1e293b;
}

/* ---- Game screen: Visily layout (white shell, vertical sections) ---- */
.game-page,
#game-screen {
  position: relative;
  justify-content: flex-start;
  padding: 0;
  background: #fff;
  min-height: 100vh;
  max-width: 100%;
}

/* App header: logo, theme pills, settings */
.app-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.75rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}

.app-header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-logo {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #e94560 0%, #6366f1 100%);
  border-radius: 6px;
  clip-path: polygon(20% 80%, 50% 20%, 80% 80%, 50% 50%);
}

.app-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: #1e293b;
}

.theme-pills {
  display: flex;
  gap: 0.35rem;
}

.theme-pill {
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #f8fafc;
  color: #475569;
  cursor: pointer;
}

.theme-pill:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.theme-pill.active {
  background: #e0f2fe;
  border-color: #0ea5e9;
  color: #0369a1;
}

.theme-pill.disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

.coming-soon-flash {
  position: fixed;
  top: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  background: #334155;
  color: #fff;
  padding: 0.5rem 1.2rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s;
}

.coming-soon-flash.show {
  opacity: 1;
}

.app-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: #f1f5f9;
  color: #475569;
  font-size: 1.1rem;
  cursor: pointer;
}

.icon-btn:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #94a3b8, #64748b);
}

/* Resource strip: level, colored blocks, efficiency */
.resource-strip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  width: 100%;
  padding: 0.6rem 1.5rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.resource-strip-level .level-badge {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #0369a1;
  background: #e0f2fe;
  border-radius: 8px;
}

.resource-blocks {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.resource-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.resource-block-bar {
  width: 100%;
  height: 4px;
  border-radius: 2px;
}

.resource-block-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #64748b;
}

.resource-block-value {
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.resource-efficiency {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.efficiency-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}

.efficiency-value {
  font-size: 1rem;
  font-weight: 700;
  color: #16a34a;
}

/* Ring area: canvas + sync card overlay */
.ring-area {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 1rem;
}

.sync-card {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 5;
  padding: 0.6rem 1rem;
  background: #e0f2fe;
  border-radius: 10px;
  min-width: 100px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.sync-card-title {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 0.2rem;
}

.sync-percent {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #1e293b;
}

.sync-bar {
  height: 4px;
  background: #cbd5e1;
  border-radius: 2px;
  margin-top: 0.35rem;
  overflow: hidden;
}

.sync-bar-fill {
  height: 100%;
  background: #0ea5e9;
  border-radius: 2px;
  transition: width 0.15s ease;
}

/* Always-visible shop bar (market) */
.shop-bar {
  flex: 0 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
}

.shop-bar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.shop-bar-row .f-key-indicator {
  margin-left: 0;
  margin-right: auto;
}

.shop-bar-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.shop-bar .shop-btn {
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
}

.shop-bar .btn-menu {
  padding: 0.4rem 0.8rem;
  font-size: 0.9rem;
}

/* Bottom control pill */
.control-pill {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  margin-bottom: 0.5rem;
}

.control-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  border: none;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.control-pill-btn:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.control-pill-primary {
  background: #2563eb;
  color: #fff;
}

.control-pill-primary:hover {
  background: #1d4ed8;
  color: #fff;
}

.control-pill-icon-only {
  padding: 0.5rem 0.75rem;
}

.control-pill-icon {
  font-size: 1rem;
}

/* Footer */
.app-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.5rem 1.5rem;
  font-size: 0.8rem;
  color: #64748b;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

.app-footer-copy {
  color: #94a3b8;
}

.app-footer-status {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-tooltips {
  background: #94a3b8;
}

.status-engine {
  background: #94a3b8;
}

.status-engine.running {
  background: #22c55e;
}

.status-label {
  margin-left: 0.15rem;
}

/* Confetti overlay (first-time ring completion) */
.confetti-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  overflow: hidden;
}

.confetti-particle {
  position: absolute;
  border-radius: 2px;
  will-change: transform;
}

/* Top 1/5: money bar */
.money-bar {
  flex: 0 0 20%;
  min-height: 20vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0 1rem;
  background: #d5dce8;
  border-bottom: 2px solid #94a3b8;
  font-size: 1.5rem;
}

.money-label {
  color: #475569;
}

#money-display {
  font-weight: 700;
  font-variant-numeric: tabular-nums; /* Equal-width digits to avoid layout shift */
}

.f-key-indicator {
  margin-left: auto;
  padding: 0.25rem 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #1a1a2e;
  background: #eab308;
  border-radius: 999px;
  box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.5);
}

.f-key-indicator[hidden] {
  display: none;
}

.money-bucket {
  display: inline-block;
  min-width: 14ch; /* Fixed space per bucket so numbers don't shift layout */
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.money-bucket-label {
  color: #64748b; /* Neutral label; value uses ring color */
}

.money-bucket-value {
  font-variant-numeric: tabular-nums;
  /* color set inline per ring */
}

.shop-btn {
  padding: 0.6rem 1.2rem;
  font-size: 1rem;
  border: 2px solid #94a3b8;
  border-radius: 8px;
  background: #d5dce8;
  color: #1e293b;
  cursor: pointer;
}

.shop-btn:hover:not(:disabled) {
  background: #c8d0dc;
  /* border-color set per-button in JS to match ring color */
}

.shop-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Test toolbar: expandable content below control pill */
.test-toolbar {
  flex: 0 0 auto;
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 0 0 0.5rem;
}

.test-toolbar-content {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 8px;
  background: rgba(213, 220, 232, 0.98);
  border: 1px solid #94a3b8;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.test-toolbar-content[hidden] {
  display: none;
}

.test-ring-label {
  font-size: 0.9rem;
  color: #475569;
}

.test-ring-select {
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  background: #e8ecf2;
  border: 1px solid #94a3b8;
  border-radius: 6px;
  color: #1e293b;
  cursor: pointer;
}

#ring-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #d0d8e4;
  border-radius: 8px;
  border: 2px solid #94a3b8;
}

#ring-canvas:focus {
  outline: 2px solid #e94560;
  outline-offset: 2px;
}

.game-actions {
  flex: 0 0 auto;
  padding: 0.5rem;
}

.game-actions-legacy {
  /* Legacy row hidden; Red: Outer / Single bucket moved to shop overlay */
}

/* Suggestions modal */
.suggestions-dialog {
  max-width: 90vw;
  width: 420px;
  padding: 1.5rem;
  border: 2px solid #94a3b8;
  border-radius: 8px;
  background: #e8ecf2;
  color: #1e293b;
}

.suggestions-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.suggestions-dialog h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  color: #e94560;
}

.suggestions-hint {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: #64748b;
}

.suggestions-textarea {
  width: 100%;
  min-height: 100px;
  padding: 0.75rem;
  margin-bottom: 1rem;
  font: inherit;
  font-size: 0.95rem;
  border: 2px solid #94a3b8;
  border-radius: 6px;
  background: #fff;
  color: #1e293b;
  resize: vertical;
  box-sizing: border-box;
}

.suggestions-textarea::placeholder {
  color: #94a3b8;
}

.suggestions-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Settings dialog */
.settings-dialog {
  max-width: 90vw;
  width: 380px;
  padding: 1.5rem;
  border: 2px solid #94a3b8;
  border-radius: 8px;
  background: #e8ecf2;
  color: #1e293b;
}

.settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.settings-dialog h2 {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  color: #1e293b;
}

.settings-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.settings-actions {
  display: flex;
  gap: 0.5rem;
}
