/* Harmony Hash - Main Stylesheet */

:root {
  /* Light theme (default) - warm professional palette */
  --bg-color: #f5f1e8;
  --text-color: #1a1612;
  --cell-bg: #fdfcfa;
  --special-cell-bg: linear-gradient(135deg, #fff9e6 0%, #ffe8cc 100%);
  --border-color: #d4c5b0;
  --special-border-color: #d4c5b0;
  --button-bg: #ffffff;
  --button-hover-bg: #f0e6d6;
  --button-border: #d4c5b0;
  --button-text: #1a1612;
  --legend-color: #4a4a4a;
  --yin-color: #4a4a4a;
  --yang-color: #000000;
  --fixed-outline: #d4af37;
  --duplicate-outline: #c1121f;
  --duplicate-shadow: rgba(193, 18, 31, 0.6);
  --title-gradient: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
}

.dark-theme {
  /* Dark theme - deep blue-black mystical palette */
  --bg-color: #0f0f1e;
  --text-color: #f0f0f0;
  --cell-bg: #1a1d2e;
  --special-cell-bg: linear-gradient(135deg, #2d1b4e 0%, #1a1d2e 100%);
  --border-color: #2d3561;
  --special-border-color: #2d3561;
  --button-bg: #1a1d2e;
  --button-hover-bg: #2d3561;
  --button-border: #2d3561;
  --button-text: #f0f0f0;
  --legend-color: #c9d6df;
  --yin-color: #c9d6df;
  --yang-color: #ffffff;
  --fixed-outline: #f4d03f;
  --duplicate-outline: #e53935;
  --duplicate-shadow: rgba(229, 57, 53, 0.6);
  --title-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  transition: background-color 0.3s ease, color 0.3s ease;
  box-sizing: border-box;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100vh;
  width: 100%;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  box-sizing: border-box;
  overflow-y: auto;
}

h1 {
  margin-top: 0;
  margin-bottom: 20px;
  flex-shrink: 0;
}

#donation {
  margin-top: 20px;
  margin-bottom: 0;
  flex-shrink: 0;
}

h1 {
  font-size: clamp(20px, 5vw, 42px);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: clamp(4px, 1.5vw, 12px);
  text-align: center;
  background: var(--title-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#hearts, #score, #rulesBtn {
  font-size: clamp(10px, 2.5vw, 16px);
  font-weight: 600;
  padding: clamp(3px, 1vw, 6px) clamp(6px, 2vw, 14px);
  background: var(--cell-bg);
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  display: inline-block;
  margin: 0 clamp(2px, 0.5vw, 4px);
}

#rulesBtn {
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

#rulesBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

#rulesBtn:active {
  transform: translateY(0);
}

#stats-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(2px, 1vw, 8px);
  margin-bottom: clamp(6px, 2vw, 18px);
  flex-wrap: wrap;
}

#board {
  display: grid;
  grid-template-columns: repeat(8, minmax(30px, 1fr));
  grid-template-rows: repeat(8, minmax(30px, 1fr));
  gap: clamp(0.5px, 1vw, 4px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  border-radius: clamp(6px, 2vw, 12px);
  padding: clamp(2px, 2vw, 12px);
  background: var(--cell-bg);
  margin: 0 auto;
  width: min(564px, min(90vw, calc(100vh - 300px)));
  height: min(564px, min(90vw, calc(100vh - 300px)));
  max-width: 100%;
  max-height: 100%;
  box-sizing: border-box;
  touch-action: none;
  flex-shrink: 0;
}

.cell {
  min-height: 0;
  aspect-ratio: 1;
  border-radius: clamp(4px, 1vw, 6px);
}

button {
  margin: clamp(3px, 1vw, 6px) 0;
  padding: clamp(5px, 1.5vw, 10px) clamp(8px, 2.5vw, 18px);
  background: var(--button-bg);
  color: var(--button-text);
  border: 1px solid var(--button-border);
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: clamp(6px, 1.5vw, 8px);
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  font-size: clamp(10px, 2.5vw, 16px);
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

button:active {
  transform: translateY(0);
}

#controls {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: clamp(2px, 1vw, 8px);
  margin: 0;
  justify-content: center;
  justify-items: center;
}

#theme-language-controls {
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: clamp(2px, 1vw, 8px);
  margin: 0 0 clamp(4px, 1.5vw, 12px) 0;
  justify-content: center;
  justify-items: center;
}

#status {
  font-size: clamp(10px, 2.5vw, 14px);
  margin-top: clamp(4px, 1.5vw, 12px);
  color: var(--text-color);
  text-align: center;
  min-height: clamp(10px, 2vw, 18px);
}

#timer-container {
  margin-top: clamp(6px, 2vw, 16px);
}

#timer-container > div {
  font-size: clamp(10px, 2.5vw, 14px);
  color: var(--text-color);
  margin-bottom: clamp(0, 0.5vw, 4px);
}

/* Device-specific fine-tuning for iPhone 12/14 Max */
@media (min-width: 390px) and (max-width: 430px) and (min-height: 844px) and (max-height: 932px) {
  /* iPhone 12/14 Max range */
  .yin, .yang {
    font-size: clamp(7px, 1.8vmin, 13px);
  }
  .element {
    font-size: clamp(5px, 1.2vmin, 11px);
  }
  .element > div {
    margin: 0.08vmin 0;
    line-height: 0.45;
  }
}

/* Additional fine-tuning for very tall screens */
@media (min-height: 900px) and (max-width: 430px) {
  #board {
    width: min(400px, min(95vw, calc(100vh - 280px)));
    height: min(400px, min(95vw, calc(100vh - 280px)));
  }
}

.cell {
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cell-bg);
  cursor: pointer;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  border-radius: clamp(4px, 1vw, 6px);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.08);
}

.cell:hover {
  border-color: var(--fixed-outline);
  box-shadow: inset 0 1px 3px rgba(212, 175, 55, 0.2), 0 0 8px rgba(212, 175, 55, 0.15);
}

.cell.special {
  background: var(--special-cell-bg);
  border-color: var(--special-border-color);
  box-shadow: 0 0 20px rgba(212, 175, 55, 0.2);
}

.cell.duplicate {
  outline: 2px solid var(--duplicate-outline);
  box-shadow: 0 0 6px var(--duplicate-shadow);
}

.cell.blocked {
  border: none;
  background: transparent;
  box-shadow: none;
  cursor: default;
  pointer-events: none;
}

.cell.blocked:hover {
  border: none;
  box-shadow: none;
}

.element {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  font-size: clamp(6px, 1.5vmin, 12px);
  line-height: 0.8;
}

.element > div {
  margin: 0.1vmin 0;
  line-height: 0.5;
  font-family: monospace;
  font-weight: 700;
}

.yin {
  color: var(--yin-color);
  font-size: clamp(8px, 2vmin, 14px);
}

.yang {
  color: var(--yang-color);
  font-size: clamp(8px, 2vmin, 14px);
}

/* Animations - Subtle border/color animations only */
@keyframes borderGlow {
  0%, 100% { 
    outline-color: var(--fixed-outline);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
  }
  50% { 
    outline-color: #ffd700;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
  }
}

@keyframes subtlePulse {
  0%, 100% { 
    border-color: var(--border-color);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.08);
  }
  50% { 
    border-color: var(--fixed-outline);
    box-shadow: inset 0 1px 3px rgba(212, 175, 55, 0.3), 0 0 8px rgba(212, 175, 55, 0.2);
  }
}

.cell.fixed {
  outline: 3px solid var(--fixed-outline);
  box-shadow: 0 0 15px rgba(212, 175, 55, 0.4);
  animation: borderGlow 1.5s ease-in-out infinite;
}

/* Modal overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  backdrop-filter: blur(6px);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Modal box */
.modal {
  background: var(--bg-color);
  color: var(--text-color);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: clamp(12px, 3vw, 16px);
  max-width: 520px; /* Slightly smaller than board width (564px) */
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  padding: clamp(12px, 3vw, 20px);
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  box-sizing: border-box;
  margin: 0 clamp(10px, 3vw, 20px);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: clamp(10px, 2vw, 15px);
  border-bottom: 2px solid var(--fixed-outline);
  padding-bottom: clamp(8px, 1.5vw, 12px);
}

.modal-title {
  font-size: clamp(15px, 3vw, 18px);
  font-weight: bold;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: clamp(20px, 4vw, 24px);
  line-height: 1;
  cursor: pointer;
  color: var(--text-color);
  padding: 0;
  width: clamp(25px, 5vw, 30px);
  height: clamp(25px, 5vw, 30px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background-color: rgba(255,0,0,0.1);
  transform: rotate(90deg);
}

.modal-content {
  font-size: clamp(12px, 2.5vw, 14px);
  line-height: 1.5;
  overflow-wrap: break-word;
  word-wrap: break-word;
  hyphens: auto;
}

.modal-content h3 {
  margin-top: 1em;
  margin-bottom: 0.5em;
  color: var(--fixed-outline);
  font-family: monospace;
  font-size: clamp(14px, 3vw, 16px);
}

.modal-content .rules-section {
  margin-bottom: clamp(0.8em, 2vw, 1.2em);
}

.modal-content p {
  margin: 0.5em 0;
}

.modal-content ul {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.modal-content li {
  margin: 0.3em 0;
}

#autoPlayBtn.start {
  border-color: #00a896;
  color: #00a896;
}

#autoPlayBtn.stop {
  border-color: #c1121f;
  color: #c1121f;
}

/* © 2025 Alexandre Michel Gavronski. All rights reserved. */
