/* Cozy Cat Sudoku Design Tokens */
:root {
  --bg-primary: #fdf5f5;          /* Fluffy cat milk background */
  --bg-card: #ffffff;
  --primary-color: #ff888b;       /* Cute salmon cat nose color */
  --primary-hover: #ff7276;
  --secondary-color: #c2c9ff;     /* Fluffy lavender toy */
  --secondary-hover: #b0b8ff;
  --accent-color: #ffdef0;        /* Pink jelly paw pads */
  --border-thin: #ffe3e3;
  --border-thick: #ff888b;
  
  --text-main: #5f4848;           /* Cozy cocoa brown text */
  --text-light: #ab9292;
  --cell-initial: #fff1f1;        /* Light peach clue background */
  --cell-hover: #fff9fc;
  --cell-selected: #ffd7e9;       /* Pink selection */
  --cell-highlight-area: #fff7f7;
  --cell-highlight-value: #ffd1cd;
  
  --shadow-main: 0 10px 30px rgba(255, 136, 139, 0.12);
  --shadow-button: 0 4px 12px rgba(255, 136, 139, 0.25);
  --font-cute: 'Fredoka', 'Gaegu', 'Outfit', sans-serif;
  --font-korean: 'Gaegu', 'Outfit', sans-serif;
}

/* Reset and Global Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-cute);
  color: var(--text-main);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(var(--accent-color) 1.2px, transparent 1.2px), 
    radial-gradient(var(--accent-color) 1.2px, var(--bg-primary) 1.2px);
  background-size: 40px 40px;
  background-position: 0 0, 20px 20px;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
  overflow-x: hidden;
}

/* Main Container Wrapper */
.app-container {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: center;
  width: 95vw;
  max-width: 1000px;
  height: 92vh;
  max-height: 92vh;
  background-color: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border: 4px solid var(--border-thin);
  border-radius: 30px;
  padding: 20px;
  box-shadow: var(--shadow-main);
  gap: 20px;
}

/* Header Styles */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px dashed var(--border-thin);
  padding-bottom: 12px;
}

.brand-title {
  font-family: var(--font-korean);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-main);
  text-shadow: 1px 1px 0px #ffffff;
}

.top-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* General Button Styles */
.btn {
  font-family: var(--font-cute);
  font-weight: 600;
  border: none;
  border-radius: 12px;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  font-size: 0.9rem;
}

.btn:active {
  transform: scale(0.95);
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
  box-shadow: var(--shadow-button);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: #ffffff;
  color: var(--text-main);
  border: 2px solid var(--border-thin);
}

.btn-secondary:hover {
  background-color: var(--bg-primary);
}

.lang-toggle {
  display: flex;
  background: white;
  border: 2px solid var(--border-thin);
  border-radius: 12px;
  padding: 2px;
}

.btn-lang {
  background: transparent;
  color: var(--text-light);
  padding: 4px 8px;
  font-size: 0.8rem;
  border-radius: 8px;
}

.btn-lang.active {
  background-color: var(--accent-color);
  color: var(--text-main);
  font-weight: 700;
}

/* Difficulty Section */
.difficulty-section {
  display: flex;
  justify-content: space-between;
  gap: 5px;
}

.diff-btn {
  flex: 1;
  background-color: white;
  color: var(--text-light);
  border: 2px solid var(--border-thin);
  padding: 6px 4px;
  font-size: 0.85rem;
}

.diff-btn.active {
  background-color: var(--accent-color);
  color: var(--text-main);
  border-color: var(--border-thick);
  font-weight: 700;
}

/* Dashboard Panel */
.dashboard-section {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.dashboard-card {
  background: white;
  border: 2px solid var(--border-thin);
  border-radius: 16px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.dash-label {
  font-family: var(--font-korean);
  font-size: 0.75rem;
  color: var(--text-light);
}

.dash-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.mistakes-row {
  display: flex;
  gap: 3px;
  font-size: 1.1rem;
}

/* Sudoku Board Layout */
.board-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.sudoku-container {
  position: relative;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  max-height: 100%;
  max-width: 100%;
  background-color: white;
  border: 4px solid var(--border-thick);
  border-radius: 20px;
  box-shadow: var(--shadow-main);
  overflow: hidden;
}

/* Sidebar Dashboard Layout */
.sidebar-dashboard {
  width: 290px;
  flex: 0 0 290px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  overflow-y: auto;
  padding-right: 4px;
}

.sidebar-dashboard::-webkit-scrollbar {
  width: 6px;
}
.sidebar-dashboard::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-dashboard::-webkit-scrollbar-thumb {
  background: var(--border-thin);
  border-radius: 10px;
}
.sidebar-dashboard::-webkit-scrollbar-thumb:hover {
  background: var(--border-thick);
}

.sudoku-container.blurred {
  filter: blur(8px);
  pointer-events: none;
}

.sudoku-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  width: 100%;
  height: 100%;
}

/* Cell Styles */
.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--text-main);
  background-color: white;
  border: 1px solid var(--border-thin);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

/* Thick borders separating 3x3 regions */
.cell.border-right {
  border-right: 3px solid var(--border-thick);
}

.cell.border-bottom {
  border-bottom: 3px solid var(--border-thick);
}

/* Special Cell States */
.cell.initial {
  background-color: var(--cell-initial);
  font-weight: 700;
}

.cell.inputted {
  color: #ff5e62;
  animation: numPop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Cell Highlighting */
.cell.highlight-area {
  background-color: var(--cell-highlight-area);
}

.cell.highlight-value {
  background-color: var(--cell-highlight-value);
  transform: scale(1.03);
  z-index: 2;
  box-shadow: 0 0 6px rgba(255, 136, 139, 0.3);
}

.cell.selected {
  background-color: var(--cell-selected) !important;
  box-shadow: inset 0 0 0 3px var(--border-thick);
  z-index: 3;
}

/* Cell Animations */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.cell.mistake {
  background-color: #ffdad9 !important;
  color: #ff2e2e !important;
  animation: shake 0.4s ease-in-out;
}

@keyframes correctPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); background-color: #d8f5d1; }
  100% { transform: scale(1); }
}

.cell.correct-highlight {
  animation: correctPop 0.8s ease;
  color: #2e7d32 !important;
  font-weight: 700;
}

@keyframes numPop {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Pencil Notes inside Cell */
.cell.has-notes {
  padding: 3px;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 100%;
  height: 100%;
}

.note-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-light);
  line-height: 1;
}

/* Action controls underneath board */
.controls-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quick-actions {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.btn-action {
  flex: 1;
  background-color: white;
  border: 2px solid var(--border-thin);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 2px;
}

.btn-action.active {
  background-color: var(--accent-color);
  border-color: var(--border-thick);
}

.action-icon {
  font-size: 1.1rem;
}

.action-label {
  font-family: var(--font-korean);
  font-size: 0.75rem;
  font-weight: 700;
}

/* Input Keypad */
.numpad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.num-btn {
  background-color: white;
  color: var(--text-main);
  border: 2px solid var(--border-thin);
  border-radius: 14px;
  font-size: 1.5rem;
  font-weight: 700;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.num-btn:hover {
  background-color: var(--bg-primary);
  border-color: var(--border-thick);
}

.num-btn:active {
  transform: scale(0.92);
}

.num-clear-btn {
  background-color: #fff2f2;
  border-color: #ffcccc;
  font-size: 1.1rem;
}

.btn-new-game {
  width: 100%;
  padding: 12px;
  font-size: 1.1rem;
  font-weight: 700;
}

/* Collapsible Keyboard Guide */
.kb-guide {
  background: white;
  border: 2px dashed var(--border-thin);
  border-radius: 14px;
  padding: 8px 12px;
}

.kb-title {
  font-family: var(--font-korean);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-light);
  outline: none;
}

.kb-desc {
  font-family: var(--font-korean);
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 6px;
  line-height: 1.4;
}

/* ==================== OVERLAYS & MODALS ==================== */

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.overlay-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sleeping-cat {
  font-size: 3rem;
  animation: float 2s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.hidden {
  display: none !important;
}

/* Modals System */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(95, 72, 72, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-card {
  background: white;
  border-radius: 26px;
  padding: 25px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
  border: 4px solid var(--border-thin);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.modal-cat-icon {
  font-size: 2.8rem;
}

.modal-title {
  font-family: var(--font-korean);
  font-size: 1.6rem;
  font-weight: 700;
}

.text-danger { color: #d32f2f; }
.text-success { color: #388e3c; }

.modal-body {
  font-family: var(--font-korean);
  font-size: 0.95rem;
  color: var(--text-light);
  line-height: 1.5;
}

/* Entrance Animations */
@keyframes bounceIn {
  0% { transform: scale(0.85); opacity: 0; }
  70% { transform: scale(1.04); }
  100% { transform: scale(1); opacity: 1; }
}

.bounce-in {
  animation: bounceIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.2) forwards;
}

/* New Record Entries Row */
.record-info-row {
  display: flex;
  gap: 10px;
}

.record-info-box {
  flex: 1;
  background-color: var(--bg-primary);
  border: 2px solid var(--border-thin);
  border-radius: 14px;
  padding: 8px;
  display: flex;
  flex-direction: column;
}

.info-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-light);
}

.info-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Nickname Inputs */
.input-group input {
  width: 100%;
  padding: 12px;
  border-radius: 14px;
  border: 2px solid var(--border-thin);
  font-family: var(--font-cute);
  font-size: 1rem;
  text-align: center;
  color: var(--text-main);
  outline: none;
}

.input-group input:focus {
  border-color: var(--border-thick);
  background-color: var(--bg-primary);
}

.modal-actions {
  display: flex;
  gap: 8px;
}

.modal-actions button {
  flex: 1;
}

/* Leaderboard Tables styles */
.leaderboard-card {
  max-width: 440px;
}

.leaderboard-notice {
  font-family: var(--font-korean);
  font-size: 0.85rem;
  color: var(--primary-color);
  background-color: var(--cell-initial);
  padding: 6px;
  border-radius: 10px;
}

.leaderboard-table-wrapper {
  max-height: 250px;
  overflow-y: auto;
  border: 2px solid var(--border-thin);
  border-radius: 16px;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.leaderboard-table th, .leaderboard-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border-thin);
}

.leaderboard-table th {
  background-color: var(--bg-primary);
  font-family: var(--font-korean);
  font-weight: 700;
  color: var(--text-main);
  position: sticky;
  top: 0;
}

.leaderboard-table tbody tr:hover {
  background-color: var(--bg-primary);
}

/* Podiums style colors */
.rank-gold {
  background-color: #fff9e6;
  font-weight: bold;
}
.rank-silver {
  background-color: #f7f7f9;
}
.rank-bronze {
  background-color: #faf3ee;
}

/* Responsive adjustments */
@media (max-width: 767px) {
  body {
    padding: 8px;
    align-items: flex-start;
  }

  .app-container {
    flex-direction: column;
    height: auto;
    max-height: none;
    width: 100%;
    max-width: 460px;
    padding: 16px;
    gap: 12px;
    border-radius: 24px;
  }

  .board-area {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
  }

  .sudoku-container {
    width: 100%;
    height: 100%;
    aspect-ratio: 1 / 1;
    max-width: none;
    max-height: none;
  }

  .sidebar-dashboard {
    width: 100%;
    flex: none;
    height: auto;
    overflow-y: visible;
    padding-right: 0;
    gap: 12px;
  }
}

@media (max-width: 480px) {
  .app-container {
    padding: 12px;
    border-radius: 18px;
    gap: 10px;
  }
  
  .brand-title {
    font-size: 1.25rem;
  }

  .cell {
    font-size: 1.3rem;
  }

  .note-cell {
    font-size: 0.5rem;
  }
  
  .num-btn {
    font-size: 1.2rem;
    height: 40px;
    border-radius: 10px;
  }
}
