/* ==========================================================================
   Global Reset & Base Styles
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--color-bg-darkest);
  background-image: radial-gradient(
    circle at 50% 30%,
    hsl(225, 25%, 15%) 0%,
    var(--color-bg-darkest) 70%
  );
  color: var(--color-text-primary);
  font-family: var(--font-family-sans);
  min-height: 100dvh;
  overflow-x: hidden;
  display: flex;
  padding: 1.5rem;
}

/* Prevent default browser focus outline on programmatically focused headings */
h1:focus,
h2:focus,
h3:focus,
h4:focus,
h5:focus,
h6:focus {
  outline: none;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--color-bg-darkest);
}
::-webkit-scrollbar-thumb {
  background: hsl(225, 15%, 22%);
  border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
  background: hsl(225, 15%, 30%);
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1240px;
  min-height: calc(100dvh - 3rem);
  flex: 1;
  box-sizing: border-box;
  height: auto;
  margin: auto;
  gap: 1rem;
  padding: 0.75rem 1rem;
}

/* Views & View Manager */
.view-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.view-layout {
  gap: 1.5rem;
}

.view-container.hidden,
.hidden {
  display: none !important;
}

/* ==========================================================================
   Buttons & UI Elements
   ========================================================================== */
.btn {
  font-family: var(--font-family-sans);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 100px;
}

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

.btn-primary {
  background: var(--color-gold);
  color: var(--color-bg-darkest);
}
.btn-primary:hover:not(:disabled) {
  background: hsl(45, 95%, 60%);
  box-shadow: 0 0 10px var(--color-gold-glow);
}

.btn-secondary {
  background: hsla(0, 0%, 100%, 0.08);
  color: var(--color-text-primary);
  border: 1px solid hsla(0, 0%, 100%, 0.1);
}
.btn-secondary:hover:not(:disabled) {
  background: hsla(0, 0%, 100%, 0.15);
}

.btn-danger {
  background: var(--color-ruby);
  color: var(--color-text-primary);
  box-shadow: 0 0 10px var(--color-ruby-glow);
}
.btn-danger:hover:not(:disabled) {
  background: hsl(342, 85%, 60%);
}

.btn-outline {
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid hsla(0, 0%, 100%, 0.1);
}
.btn-outline:hover:not(:disabled) {
  color: var(--color-text-primary);
  border-color: hsla(0, 0%, 100%, 0.3);
}

.btn-warning {
  color: var(--color-amber);
  border-color: var(--color-amber-glow);
}
.btn-warning:hover:not(:disabled) {
  background: var(--color-amber-glow);
  color: var(--color-text-primary);
}

.btn-block {
  width: 100%;
  padding: 0.75rem;
  font-size: 0.9rem;
}

.btn-lg {
  padding: 0.85rem 2rem;
  font-size: 0.95rem;
  border-radius: var(--radius-md);
}

/* ==========================================================================
   Dialog (Modal) Overlay Styles
   ========================================================================== */
dialog {
  border: var(--border-glass-focus);
  border-radius: var(--radius-lg);
  background: hsl(225, 20%, 14%);
  color: var(--color-text-primary);
  box-shadow:
    var(--shadow-glass),
    0 0 100px rgba(0, 0, 0, 0.8);
  padding: 2rem;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 500px;
  width: 90%;
  outline: none;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
}

.dialog-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.dialog-content h2 {
  font-family: var(--font-family-title);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--color-gold);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.text-center {
  text-align: center;
}

#game-over-title {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

#game-over-message {
  color: var(--color-text-secondary);
  font-size: 1rem;
  margin-bottom: 1rem;
}

/* ==========================================================================
   Toast Notification System
   ========================================================================== */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
  max-width: 360px;
  width: calc(100% - 3rem);
}

.toast {
  pointer-events: auto;
  background: hsla(225, 20%, 12%, 0.85);
  backdrop-filter: var(--blur-glass);
  -webkit-backdrop-filter: var(--blur-glass);
  color: var(--color-text-primary);
  border: var(--border-glass);
  border-left: 4px solid var(--toast-border-color, var(--color-ruby));
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-md);
  box-shadow:
    var(--shadow-glass),
    0 10px 30px rgba(0, 0, 0, 0.4);
  font-family: var(--font-family-sans);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  opacity: 0;
  transform: translateY(-20px) scale(0.95);
  transition:
    opacity 0.35s cubic-bezier(0.25, 0.8, 0.25, 1),
    transform 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast.hide {
  opacity: 0;
  transform: translateY(-15px) scale(0.95);
}

.toast-success {
  --toast-border-color: var(--color-emerald);
  box-shadow:
    0 0 15px hsla(152, 75%, 43%, 0.15),
    var(--shadow-glass);
}

.toast-error {
  --toast-border-color: var(--color-ruby);
  box-shadow:
    0 0 15px hsla(342, 85%, 52%, 0.15),
    var(--shadow-glass);
}

.toast-info {
  --toast-border-color: var(--color-gold);
  box-shadow:
    0 0 15px hsla(45, 95%, 50%, 0.15),
    var(--shadow-glass);
}

.toast-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    color var(--transition-fast),
    transform var(--transition-fast);
}

.toast-close:hover {
  color: var(--color-text-primary);
  transform: scale(1.1);
}

/* ==========================================================================
   Audio & Haptic Feedback Control Styles
   ========================================================================== */
.audio-haptics-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.5rem;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.08);
  border: var(--border-glass);
  border-radius: var(--radius-md);
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  color: var(--color-text-primary);
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.25);
}

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

.btn-icon.muted {
  opacity: 0.45;
  filter: grayscale(0.8);
  background: rgba(0, 0, 0, 0.25);
}

/* ==========================================================================
   Footer Styles
   ========================================================================== */
.app-view-footer {
  text-align: center;
  padding: 1.25rem 0 0.5rem 0;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  border-top: var(--border-glass);
  margin-top: 1.5rem;
  flex-shrink: 0;
}

.app-view-footer a {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition-fast);
}

.app-view-footer a:hover {
  color: var(--color-gold);
  text-decoration: underline;
}

.game-view-footer {
  text-align: center;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  opacity: 0.6;
  margin-top: 0.75rem;
  flex-shrink: 0;
  transition: opacity var(--transition-fast);
}

.game-view-footer:hover {
  opacity: 1;
}

.game-view-footer a {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition-fast);
}

.game-view-footer a:hover {
  color: var(--color-gold);
  text-decoration: underline;
}
