/* Suki Kanji Park - Premium Educational Study-themed Design System */

:root {
  --bg-gradient: linear-gradient(135deg, #fbf7ee 0%, #eef7f2 100%);
  --text-dark: #3a3227;
  
  /* Classy Study Theme Colors */
  --pastel-pink: #f7a7b8;
  --pastel-pink-shadow: #d68798;
  --pastel-green: #90d3a5;
  --pastel-green-shadow: #70b385;
  --pastel-yellow: #fcd55c;
  --pastel-yellow-shadow: #dbb33a;
  --pastel-orange: #fca35c;
  --pastel-orange-shadow: #db833a;
  --pastel-blue: #8fc7f4;
  --pastel-blue-shadow: #6fa7d4;

  --font-study: 'M PLUS Rounded 1c', 'Noto Sans JP', sans-serif;
  --font-textbook: 'Klee One', 'M PLUS Rounded 1c', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  background: var(--bg-gradient);
  color: var(--text-dark);
  font-family: var(--font-study);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  padding: 10px;
}

/* Container locking aspect-ratio for study desk aesthetic */
.game-container {
  width: 1024px;
  max-width: 100%;
  height: 720px;
  max-height: 100vh;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  border: 6px solid #fff;
  border-radius: 36px;
  box-shadow: 0 20px 50px rgba(110, 95, 80, 0.15);
  position: relative;
  overflow: hidden;
}

/* Screen Wrapper */
.screen {
  width: 100%;
  height: 100%;
  padding: 30px;
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0; left: 0;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.15), opacity 0.3s;
}

.screen.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(30px);
}

.hidden {
  display: none !important;
}

/* --- Menu Screen Layout --- */
.app-header {
  text-align: center;
  margin-bottom: 25px;
}

.app-logo {
  font-size: 3.8rem;
  font-weight: 900;
  color: #ff5b94;
  letter-spacing: 2px;
  text-shadow: 0 4px 0 #fff, 0 8px 0 rgba(255, 91, 148, 0.12);
  display: flex;
  justify-content: center;
  gap: 12px;
  font-family: var(--font-textbook);
}

.app-logo span:nth-child(2) {
  color: #2ca58d;
  text-shadow: 0 4px 0 #fff, 0 8px 0 rgba(44, 165, 141, 0.12);
}

.app-subtitle {
  font-size: 1.4rem;
  font-weight: 700;
  color: #8c7e6b;
  margin-top: 5px;
}

/* settings and select panel styles */
.settings-panel {
  background: rgba(255, 255, 255, 0.8);
  border: 2px dashed rgba(58, 50, 39, 0.15);
  border-radius: 24px;
  padding: 16px 24px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.02);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.setting-label {
  font-weight: 900;
  font-size: 1.15rem;
  color: var(--text-dark);
}

.select-bubble {
  background: #fff;
  border: 3px solid #3a3227;
  border-radius: 14px;
  padding: 8px 18px;
  font-family: var(--font-study);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-dark);
  outline: none;
  cursor: pointer;
  box-shadow: 0 4px 0 #3a3227;
  transition: transform 0.1s, box-shadow 0.1s;
}

.select-bubble:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #3a3227;
}

.difficulty-options {
  display: flex;
  gap: 12px;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: auto;
}

.menu-card {
  border: none;
  border-radius: 24px;
  padding: 30px 20px;
  cursor: pointer;
  font-family: var(--font-study);
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
}

.menu-card:active {
  transform: translateY(6px);
}

.menu-card .card-icon {
  font-size: 4.8rem;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.08));
  animation: float 3s ease-in-out infinite;
}

.menu-card:nth-child(2) .card-icon { animation-delay: 0.5s; }
.menu-card:nth-child(3) .card-icon { animation-delay: 1s; }

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

.menu-card h3 {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--text-dark);
}

.menu-card p {
  font-size: 1.05rem;
  font-weight: 700;
  color: rgba(58, 50, 39, 0.6);
}

/* 3D Color Cards */
.pink-card {
  background: var(--pastel-pink);
  border-bottom: 8px solid var(--pastel-pink-shadow);
  box-shadow: 0 8px 0 rgba(214, 135, 152, 0.25);
}
.pink-card:active { border-bottom-width: 2px; box-shadow: 0 2px 0 rgba(214, 135, 152, 0.25); }

.green-card {
  background: var(--pastel-green);
  border-bottom: 8px solid var(--pastel-green-shadow);
  box-shadow: 0 8px 0 rgba(112, 179, 133, 0.25);
}
.green-card:active { border-bottom-width: 2px; box-shadow: 0 2px 0 rgba(112, 179, 133, 0.25); }

.yellow-card {
  background: var(--pastel-yellow);
  border-bottom: 8px solid var(--pastel-yellow-shadow);
  box-shadow: 0 8px 0 rgba(219, 179, 58, 0.25);
}
.yellow-card:active { border-bottom-width: 2px; box-shadow: 0 2px 0 rgba(219, 179, 58, 0.25); }

.menu-footer {
  text-align: center;
  margin-top: 15px;
}

.btn-back-portfolio {
  background: transparent;
  border: none;
  font-family: var(--font-study);
  font-size: 1.1rem;
  font-weight: 700;
  color: #8c7e6b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: color 0.2s;
}

.btn-back-portfolio:hover {
  color: #ff5b94;
}

/* Bubble buttons */
.btn-bubble {
  border: none;
  border-radius: 16px;
  padding: 10px 22px;
  font-family: var(--font-study);
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--text-dark);
  cursor: pointer;
  transition: transform 0.15s, border-width 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-bubble:active {
  transform: translateY(4px);
  border-bottom-width: 2px !important;
}

.btn-orange {
  background: var(--pastel-orange);
  border-bottom: 6px solid var(--pastel-orange-shadow);
}
.btn-green {
  background: var(--pastel-green);
  border-bottom: 6px solid var(--pastel-green-shadow);
}
.btn-yellow {
  background: var(--pastel-yellow);
  border-bottom: 6px solid var(--pastel-yellow-shadow);
}

.active-level {
  outline: 3px solid var(--text-dark);
  outline-offset: -3px;
}

/* --- Common Game Headers --- */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.header-actions {
  display: flex;
  gap: 12px;
}

.btn-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid #3a3227;
  background: #fff;
  color: var(--text-dark);
  cursor: pointer;
  box-shadow: 0 4px 0 #3a3227;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, box-shadow 0.1s;
}

.btn-icon:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #3a3227;
}

.btn-icon svg, .btn-voice-replay svg {
  pointer-events: none;
}

.game-title {
  font-size: 2.1rem;
  font-weight: 900;
  color: var(--text-dark);
  font-family: var(--font-textbook);
}

.btn-voice-replay {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid #3a3227;
  background: var(--pastel-blue);
  box-shadow: 0 5px 0 #3a3227;
  color: var(--text-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, box-shadow 0.1s;
}

.btn-voice-replay:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #3a3227;
}

.btn-voice-replay i {
  width: 28px;
  height: 28px;
}

/* --- Quiz Screen Content --- */
.quiz-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
  justify-content: center;
}

.quiz-visual-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 40px;
}

.visual-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.quiz-image {
  font-size: 9rem;
  width: 200px;
  height: 200px;
  background: #fff;
  border: 4px solid #3a3227;
  border-radius: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 0 #3a3227;
  transform: rotate(-3deg);
}

.quiz-word-places {
  display: flex;
  gap: 16px;
}

.char-slot {
  width: 90px;
  height: 90px;
  border: 4px dashed #a89f92;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--text-dark);
  font-family: var(--font-textbook);
  background: rgba(255, 255, 255, 0.3);
  transition: border 0.2s, background-color 0.2s;
}

.char-slot.filled {
  border: 4px solid #3a3227;
  background: #fff;
  box-shadow: 0 4px 0 #3a3227;
}

.quiz-choices-box {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 24px;
  border: 2px dashed rgba(58, 50, 39, 0.1);
}

.choice-card {
  width: 80px;
  height: 80px;
  border: 3px solid #3a3227;
  background: #fff;
  border-radius: 20px;
  font-size: 3rem;
  font-weight: 800;
  color: var(--text-dark);
  font-family: var(--font-textbook);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 5px 0 #3a3227;
  transition: transform 0.1s, box-shadow 0.1s;
}

.choice-card:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #3a3227;
}

/* --- Trace Screen Content --- */
.trace-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.trace-char-selector {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 8px 4px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 18px;
  border: 2px dashed rgba(58, 50, 39, 0.08);
}

.trace-char-selector::-webkit-scrollbar {
  height: 6px;
}
.trace-char-selector::-webkit-scrollbar-thumb {
  background: #a89f92;
  border-radius: 3px;
}

.trace-select-btn {
  flex-shrink: 0;
  width: 58px;
  height: 58px;
  border: 3px solid #3a3227;
  background: #fff;
  border-radius: 14px;
  font-size: 2.1rem;
  font-weight: 800;
  font-family: var(--font-textbook);
  color: var(--text-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 0 #3a3227;
  transition: all 0.1s;
}

.trace-select-btn.active {
  background: var(--pastel-yellow);
  transform: translateY(2px);
  box-shadow: 0 1px 0 #3a3227;
}

.canvas-outer-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 40px;
  flex-grow: 1;
}

.canvas-inner-box {
  width: 320px;
  height: 320px;
  background: #fff;
  border: 6px solid #3a3227;
  border-radius: 28px;
  position: relative;
  box-shadow: 0 8px 0 #3a3227, inset 0 0 15px rgba(0,0,0,0.03);
  overflow: hidden;
}

.canvas-inner-box::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: 
    linear-gradient(to right, rgba(58, 50, 39, 0.06) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(58, 50, 39, 0.06) 1px, transparent 1px);
  background-size: 50% 50%;
  background-position: center;
  pointer-events: none;
}

#traceCanvas {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0; left: 0;
  z-index: 2;
  cursor: crosshair;
}

.trace-guide-char {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 190px;
  font-weight: 800;
  color: rgba(58, 50, 39, 0.08);
  font-family: var(--font-textbook);
  z-index: 1;
  pointer-events: none;
}

.trace-anim-container {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  pointer-events: none;
}

.canvas-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.canvas-controls .btn-bubble {
  padding: 12px 24px;
  width: 190px;
  justify-content: center;
  border-radius: 18px;
  font-size: 1.1rem;
}

.trace-words-info {
  background: rgba(255, 255, 255, 0.95);
  border: 3px solid #3a3227;
  border-radius: 18px;
  padding: 10px 18px;
  font-family: var(--font-study);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-dark);
  text-align: center;
  box-shadow: 0 4px 0 #3a3227;
  margin-top: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.word-badge {
  background: #fdfaf2;
  border: 2.5px solid #3a3227;
  border-radius: 10px;
  padding: 4px 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.word-badge-text {
  font-family: var(--font-textbook);
  font-size: 1.25rem;
}

.word-badge-ruby {
  font-size: 0.85rem;
  color: #8c7e6b;
  margin-left: 4px;
}

/* --- Badge Grid & Gallery --- */
.gallery-content {
  flex-grow: 1;
  overflow-y: auto;
  padding: 10px 4px;
}

.gallery-content::-webkit-scrollbar {
  width: 8px;
}
.gallery-content::-webkit-scrollbar-thumb {
  background: #a89f92;
  border-radius: 4px;
}

.badge-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
}

.badge-item {
  background: #eae3d7;
  border: 3px solid rgba(58, 50, 39, 0.15);
  border-radius: 20px;
  padding: 15px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  filter: grayscale(1);
  opacity: 0.6;
  transition: all 0.2s;
}

.badge-item.unlocked {
  background: #fff;
  border: 3px solid #3a3227;
  filter: grayscale(0);
  opacity: 1;
  cursor: pointer;
  box-shadow: 0 4px 0 #3a3227;
}

.badge-item.unlocked:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #3a3227;
}

.badge-emoji {
  font-size: 3.2rem;
}

.badge-char-label {
  font-size: 1.6rem;
  font-weight: 800;
  font-family: var(--font-textbook);
  color: var(--text-dark);
}

.badge-total {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--pastel-orange-shadow);
  background: #fff;
  border: 3px solid #3a3227;
  border-radius: 12px;
  padding: 4px 16px;
}

/* --- Celebration Modals --- */
.celebration-overlay {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(58, 50, 39, 0.45);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.celebration-box {
  background: #fff;
  border: 6px solid #3a3227;
  border-radius: 36px;
  padding: 40px 30px;
  width: 440px;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.celebration-confetti {
  font-size: 2.2rem;
  margin-bottom: 12px;
  animation: bounce 1.5s infinite;
}

.celebration-emoji {
  font-size: 6.5rem;
  margin-bottom: 16px;
}

.celebration-message {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--text-dark);
  margin-bottom: 8px;
}

.celebration-badge-alert {
  font-size: 1.15rem;
  font-weight: 700;
  color: #8c7e6b;
  margin-bottom: 24px;
}

.celebration-box .btn-bubble {
  padding: 12px 30px;
  font-size: 1.15rem;
  border-radius: 20px;
}

/* Shake Animation */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* --- Responsive & Tablet Optimizations --- */
@media (max-width: 1024px) {
  .game-container {
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: none;
  }
}

@media (max-width: 768px) {
  .screen {
    padding: 20px 15px;
  }
  
  .app-logo {
    font-size: 2.8rem;
  }
  
  .menu-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .menu-card {
    padding: 20px;
    flex-direction: row;
    align-items: center;
    text-align: left;
    gap: 20px;
  }
  
  .menu-card .card-icon {
    font-size: 3rem;
  }
  
  .quiz-visual-box {
    flex-direction: column;
    gap: 15px;
  }
  
  .quiz-image {
    width: 150px;
    height: 150px;
    font-size: 7rem;
  }
  
  .char-slot {
    width: 68px;
    height: 68px;
    font-size: 2.8rem;
  }
  
  .choice-card {
    width: 60px;
    height: 60px;
    font-size: 2.2rem;
  }
  
  .canvas-outer-wrapper {
    flex-direction: column;
    gap: 15px;
  }
  
  .canvas-inner-box {
    width: 250px;
    height: 250px;
  }
  
  .trace-guide-char {
    font-size: 150px;
  }
  
  .canvas-controls {
    flex-direction: row;
    gap: 10px;
    width: 100%;
    justify-content: center;
  }
  
  .canvas-controls .btn-bubble {
    width: auto;
    flex: 1;
    font-size: 0.95rem;
    padding: 10px;
  }
  
  .badge-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }
}

@media (max-width: 480px) {
  .badge-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
