/* 
  Futoshiki "Today" Screen CSS
  Replicates the UI, color scheme, and layout from SwiftUI code.
*/

:root {
  --accent-color: #ff6666;
  --background-color: #d7d5cb;
  --cell-size: 60px;
  --shadow-light: -2px -2px 3px rgba(255, 255, 255, 0.7);
  --shadow-dark: 2px 2px 3px rgba(0, 0, 0, 0.1);
}

/* Basic resets and body styling */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  background-color: var(--background-color);
  color: #000;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Top Bar */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
}

.title-container {
  position: relative;
  height: 60px;
  display: flex;
  align-items: center;
  opacity: 0;
  animation: fadeIn 0.3s ease-in forwards;
  animation-delay: 0.1s;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

.title-back {
  position: absolute;
  font-size: 48px;
  color: var(--accent-color);
  opacity: 0.3;
  transform: translateX(2px) translateY(2px);
}

.title-front {
  font-family: "Instrument Serif", Georgia, "Times New Roman", serif;
  font-size: 48px;
  position: relative;
}

/* How to play button */
.rules-button {
  padding: 8px 16px;
  border-radius: 20px;
  border: none;
  background-color: white;
  color: #666;
  font-size: 14px;
  box-shadow: var(--shadow-dark), var(--shadow-light);
}

/* Main content layout */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  min-height: 100%;
  gap: 20px;
  height: calc(100vh - 100px);
  overflow-y: auto;
  position: relative;
}

/* Timer label */
.timer {
  font-family: ui-monospace, monospace;
  font-size: 20px;
  color: #666;
  margin-bottom: 20px;
}

/* Puzzle container */
.puzzle-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 40px;
  left: 50%;
}

/* Grid row container */
.grid-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Individual puzzle cell */
.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  background-color: rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 24px;
  font-weight: 400;
  box-shadow: var(--shadow-dark), var(--shadow-light);
  cursor: pointer;
  user-select: none;
}

.cell.initial {
  background-color: rgba(128, 128, 128, 0.2);
  font-weight: 500;
  box-shadow: none;
  cursor: default;
}

.cell.selected {
  border: 2px solid #666;
}

/* Constraints */
.constraint {
  color: #666;
  font-size: 12px;
  width: 8px;
  text-align: center;
  user-select: none;
  line-height: 1;
  height: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.constraint.horizontal {
  width: 8px;
}

.constraint.vertical {
  height: 8px;
  width: var(--cell-size);
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0;
  white-space: nowrap;
}

.constraint-row {
  display: flex;
  gap: 8px;
  height: 8px;
  align-items: center;
  margin: 0;
  padding: 0;
}

.constraint-spacer {
  width: 8px;
}

/* Number toolbar */
.toolbar {
  display: flex;
  gap: 12px;
  padding: 20px;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--background-color);
  justify-content: center;
  z-index: 90;
}

/* Buttons inside toolbar */
.number-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background-color: white;
  color: var(--accent-color);
  font-size: 20px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-dark), var(--shadow-light);
}

.number-button.erase {
  font-size: 16px;
}

.share-button {
  padding: 12px 24px;
  border-radius: 25px;
  border: none;
  background-color: #4caf50;
  color: white;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-dark), var(--shadow-light);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Reveal overlay */
.reveal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.95); /* Increased opacity */
  /* Remove backdrop-filter as it can cause issues on iOS */
  display: flex;
  flex-direction: column;
  gap: 48px;
  justify-content: center;
  align-items: center;
  z-index: 100;
  /* Add iOS-specific properties */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.reveal-button {
  padding: 16px 32px;
  border-radius: 25px;
  border: none;
  background-color: var(--accent-color);
  color: white;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(255, 102, 102, 0.3);
  /* Add tap highlight color override for iOS */
  -webkit-tap-highlight-color: transparent;
  /* Add touch action manipulation for better touch handling */
  touch-action: manipulation;
}

/* Modal styling */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background-color: white;
  padding: 24px;
  border-radius: 12px;
  max-width: 80%;
  max-height: 80%;
  overflow-y: auto;
}

/* Rules styling */
.rules-intro {
  font-size: 1.1em;
  color: var(--text-secondary);
  margin-bottom: 2em;
}

.rules-items {
  display: flex;
  flex-direction: column;
  gap: 1.5em;
}

.rule-item {
  display: flex;
  gap: 1em;
  padding: 1em;
  background: var(--bg-secondary);
  border-radius: 8px;
}

.rule-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-color);
}

.rule-text h3 {
  font-size: 1.1em;
  margin-bottom: 0.5em;
}

.rule-text p {
  color: var(--text-secondary);
  font-size: 0.9em;
  line-height: 1.4;
}

.emoji-legend {
  margin-top: 0.5em;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5em;
}

.emoji-row {
  font-size: 0.9em;
  color: var(--text-secondary);
}

.example-paths {
  margin-top: 1.5em;
  padding: 1em;
  background: var(--bg-secondary);
  border-radius: 8px;
}

.example-paths h4 {
  font-size: 0.9em;
  color: var(--text-secondary);
  margin-bottom: 0.8em;
}

.path-example {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  margin-bottom: 0.8em;
}

.path-label {
  font-size: 0.85em;
  font-weight: 500;
}

.path-emojis {
  font-size: 1em;
}

.close-button {
  width: 100%;
  padding: 12px;
  border-radius: 20px;
  border: none;
  background-color: var(--accent-color);
  color: white;
  font-size: 16px;
  font-weight: bold;
  margin-top: 20px;
  cursor: pointer;
}

.secondary-button {
  width: 100%;
  padding: 12px;
  border-radius: 20px;
  border: none;
  background-color: #f0f0f0;
  color: #666;
  font-size: 16px;
  font-weight: bold;
  margin-top: 8px;
  cursor: pointer;
}

/* Share modal */
.share-text {
  white-space: pre-wrap;
  font-family: monospace;
  background-color: #f5f5f5;
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 16px;
}

/* Hide focus outlines */
button:focus {
  outline: none;
}

/* Mobile optimizations */
@media (max-width: 480px) {
  .main-content {
    padding: 10px;
    padding-top: 20px;
    padding-bottom: 100px;
  }

  .cell {
    width: calc(var(--cell-size) * 0.7);
    height: calc(var(--cell-size) * 0.7);
    font-size: 20px;
  }

  .title-front,
  .title-back {
    font-size: 32px;
  }

  .rules-button {
    padding: 6px 12px;
    font-size: 12px;
  }

  .number-button {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .toolbar {
    gap: 8px;
    padding: 12px;
  }

  .top-bar {
    padding: 10px;
  }

  .grid-row {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
  }

  .constraint.vertical {
    width: calc(var(--cell-size) * 0.7);
  }
}

/* Add this to the CSS file */
.hidden {
  display: none !important;
}

/* Add these styles */
.dev-options {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin: 24px 0;
}

.date-picker-container,
.reset-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.date-input {
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 16px;
}

.date-input:focus {
  outline: none;
  border-color: var(--accent-color);
}

label {
  font-weight: 500;
  color: #666;
}

/* Add specific iOS adjustments */
@supports (-webkit-touch-callout: none) {
  .main-content {
    height: calc(100vh - 100px - env(safe-area-inset-bottom));
  }

  .toolbar {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}

/* Rules Modal Styling */
.rules-modal-content {
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  padding: 0;
  display: flex;
  flex-direction: column;
  background: var(--background-color);
}

.rules-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  background: white;
  border-radius: 12px 12px 0 0;
}

.rules-header h2 {
  font-size: 24px;
  font-weight: 600;
  color: #000;
}

.icon-button {
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: #666;
  border-radius: 50%;
}

.icon-button:hover {
  background: rgba(0, 0, 0, 0.05);
}

.rules-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.rules-intro {
  text-align: center;
  margin-bottom: 32px;
  padding: 24px;
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow-dark), var(--shadow-light);
}

.rules-intro h3 {
  font-size: 28px;
  margin-bottom: 12px;
  color: var(--accent-color);
}

.rules-intro p {
  color: #666;
  font-size: 16px;
  line-height: 1.5;
}

.rules-main {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.rule-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  gap: 16px;
  box-shadow: var(--shadow-dark), var(--shadow-light);
}

.rule-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background: var(--accent-color);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.rule-content {
  flex: 1;
}

.rule-content h4 {
  font-size: 18px;
  margin-bottom: 8px;
  color: #000;
}

.rule-content p {
  color: #666;
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 16px;
}

.rule-example {
  background: var(--background-color);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  justify-content: center;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  font-family: monospace;
  font-size: 16px;
}

.mini-grid div {
  width: 32px;
  height: 32px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  box-shadow: var(--shadow-dark);
}

.inequalities {
  display: flex;
  gap: 32px;
  justify-content: center;
}

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

.inequality-example span {
  display: inline-block;
  width: 32px;
  height: 32px;
  line-height: 32px;
  background: white;
  border-radius: 4px;
  margin: 0 4px;
  box-shadow: var(--shadow-dark);
}

.inequality-example .sign {
  background: none;
  box-shadow: none;
  color: #666;
}

.inequality-example .caption {
  margin-top: 8px;
  font-size: 14px;
  color: #666;
}

.progress-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.progress-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #666;
}

.progress-item .emoji {
  font-size: 20px;
}

.path-examples {
  background: var(--background-color);
  border-radius: 8px;
  padding: 16px;
}

.path-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.path-label {
  font-weight: 500;
  min-width: 80px;
}

.path-moves {
  letter-spacing: 2px;
}

.rules-footer {
  margin-top: 32px;
  text-align: center;
}

.primary-button {
  background: var(--accent-color);
  color: white;
  border: none;
  padding: 12px 32px;
  border-radius: 25px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-dark), var(--shadow-light);
}

/* Mobile optimizations */
@media (max-width: 480px) {
  .rules-modal-content {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .rules-header {
    border-radius: 0;
  }

  .rule-card {
    flex-direction: column;
    padding: 16px;
  }

  .rule-icon {
    width: 32px;
    height: 32px;
  }

  .inequalities {
    flex-direction: column;
    gap: 16px;
  }

  .progress-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
