/* Suki Hiragana Park - Child Friendly Playful Design System */

:root {
  --bg-gradient: linear-gradient(135deg, #fff9e6 0%, #e6f7ff 100%);
  --text-dark: #3a3227;
  
  /* Warm Pastel Theme */
  --pastel-pink: #ffb8d1;
  --pastel-pink-shadow: #e094af;
  --pastel-green: #9ee8a3;
  --pastel-green-shadow: #75c97b;
  --pastel-yellow: #ffe380;
  --pastel-yellow-shadow: #d9bd4e;
  --pastel-orange: #ffb480;
  --pastel-orange-shadow: #db8e58;
  --pastel-blue: #a3e2ff;
  --pastel-blue-shadow: #75c4eb;

  --font-child: '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-child);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  padding: 10px;
}

/* Container locking aspect-ratio for tablets */
.game-container {
  width: 1024px;
  max-width: 100%;
  height: 700px;
  max-height: 100vh;
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(10px);
  border: 4px solid #fff;
  border-radius: 32px;
  box-shadow: 0 16px 40px rgba(165, 135, 100, 0.12);
  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: 40px;
}

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

.app-logo span:nth-child(2) {
  color: #00b4ff;
  text-shadow: 0 4px 0 #fff, 0 8px 0 rgba(0, 180, 255, 0.15);
}

.app-subtitle {
  font-size: 1.4rem;
  font-weight: 700;
  color: #a39582;
  margin-top: 10px;
}

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

/* Child friendly chunky 3D card button */
.menu-card {
  border: none;
  border-radius: 24px;
  padding: 30px 20px;
  cursor: pointer;
  font-family: var(--font-child);
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
}

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

.menu-card .card-icon {
  font-size: 5rem;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
  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(224, 148, 175, 0.3);
}
.pink-card:active { border-bottom-width: 2px; box-shadow: 0 2px 0 rgba(224, 148, 175, 0.3); }

.green-card {
  background: var(--pastel-green);
  border-bottom: 8px solid var(--pastel-green-shadow);
  box-shadow: 0 8px 0 rgba(117, 201, 123, 0.3);
}
.green-card:active { border-bottom-width: 2px; box-shadow: 0 2px 0 rgba(117, 201, 123, 0.3); }

.yellow-card {
  background: var(--pastel-yellow);
  border-bottom: 8px solid var(--pastel-yellow-shadow);
  box-shadow: 0 8px 0 rgba(217, 189, 78, 0.3);
}
.yellow-card:active { border-bottom-width: 2px; box-shadow: 0 2px 0 rgba(217, 189, 78, 0.3); }

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

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

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

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

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

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

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

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

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

.btn-voice-replay:active {
  transform: translateY(4px);
  border-bottom-width: 2px;
}

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

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

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

.quiz-image {
  font-size: 9.5rem;
  width: 220px;
  height: 220px;
  background: #fff;
  border-radius: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 30px rgba(165, 135, 100, 0.1);
  border: 4px solid #fff;
  transform: rotate(-3deg);
}

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

.char-slot {
  width: 84px;
  height: 84px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.6);
  border: 3px dashed rgba(58, 50, 39, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Klee One', cursive, var(--font-child);
  font-size: 3.2rem;
  font-weight: 800;
  color: #ff5b94;
  text-shadow: 0 2px 0 #fff;
  box-shadow: inset 0 4px 10px rgba(0,0,0,0.03);
}

.char-slot.filled {
  background: #fff;
  border: 3px solid var(--pastel-pink);
  box-shadow: 0 6px 12px rgba(255, 91, 148, 0.1);
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.quiz-choices-box {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  max-width: 900px;
  margin: 0 auto;
}

/* Big fluffy choice buttons */
.choice-card {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  border: none;
  background: #fff;
  font-family: 'Klee One', cursive, var(--font-child);
  font-size: 3rem;
  font-weight: 800;
  color: var(--text-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 12px rgba(165, 135, 100, 0.08);
  border-bottom: 5px solid #e0d6c8;
  transition: transform 0.1s, border-bottom 0.1s;
}

.choice-card:active {
  transform: translateY(4px);
  border-bottom-width: 2px;
}

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

.trace-char-selector {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 8px 4px;
  scrollbar-width: none;
}

.trace-char-selector::-webkit-scrollbar {
  display: none;
}

.trace-select-btn {
  flex-shrink: 0;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: #fff;
  font-family: var(--font-child);
  font-size: 1.6rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 6px rgba(0,0,0,0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dark);
  transition: all 0.2s;
}

.trace-select-btn.active {
  background: var(--pastel-green);
  color: #fff;
  font-weight: 900;
  transform: scale(1.1);
  box-shadow: 0 6px 12px rgba(158, 232, 163, 0.3);
}

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

.canvas-inner-box {
  width: 320px;
  height: 320px;
  background: #fff;
  border: 6px solid #fff;
  border-radius: 36px;
  box-shadow: 0 12px 30px rgba(165, 135, 100, 0.1);
  position: relative;
  overflow: hidden;
}

/* Red Cross dash lines for center alignment guidelines like Japanese practice notebook */
.canvas-inner-box::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: 50%;
  border-left: 2px dashed rgba(255, 91, 148, 0.25);
  z-index: 2;
  pointer-events: none;
}
.canvas-inner-box::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  border-top: 2px dashed rgba(255, 91, 148, 0.25);
  z-index: 2;
  pointer-events: none;
}

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

.trace-guide-char {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Klee One', cursive, var(--font-child);
  font-size: 13rem;
  font-weight: 800;
  color: rgba(58, 50, 39, 0.12); /* Slightly darker ghost guide text for better visibility */
  z-index: 1;
}

.trace-anim-container {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 280px;
  height: 280px;
  z-index: 3;
  pointer-events: none;
  opacity: 0.85;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

/* Child friendly 3D bubble style button */
.btn-bubble {
  border: none;
  font-family: var(--font-child);
  font-size: 1.25rem;
  font-weight: 900;
  padding: 12px 24px;
  border-radius: 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dark);
  transition: transform 0.15s, border-bottom 0.15s;
}

.btn-bubble:active {
  transform: translateY(4px);
}

.btn-orange {
  background: var(--pastel-orange);
  border-bottom: 6px solid var(--pastel-orange-shadow);
}
.btn-orange:active { border-bottom-width: 2px; }

.btn-green {
  background: var(--pastel-green);
  border-bottom: 6px solid var(--pastel-green-shadow);
  color: #fff;
}
.btn-green:active { border-bottom-width: 2px; }

.btn-yellow {
  background: var(--pastel-yellow);
  border-bottom: 6px solid var(--pastel-yellow-shadow);
}
.btn-yellow:active { border-bottom-width: 2px; }

/* --- Gallery/Badge Grid --- */
.badge-total {
  font-size: 1.3rem;
  font-weight: 900;
  background: #fff;
  padding: 6px 16px;
  border-radius: 99px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.04);
}

.gallery-content {
  flex-grow: 1;
  overflow-y: auto;
  padding: 10px 4px;
  scrollbar-width: none;
}

.gallery-content::-webkit-scrollbar {
  display: none;
}

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

.badge-item {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.4);
  border: 3px dashed rgba(58, 50, 39, 0.1);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 2.8rem;
  position: relative;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.badge-item.unlocked {
  background: #fff;
  border: 3px solid var(--pastel-yellow);
  box-shadow: 0 6px 12px rgba(255, 227, 128, 0.2);
  transform: rotate(3deg);
}

.badge-char-label {
  position: absolute;
  bottom: 6px;
  font-size: 0.85rem;
  font-weight: 900;
  background: rgba(58, 50, 39, 0.05);
  padding: 1px 8px;
  border-radius: 99px;
  color: var(--text-dark);
}

.badge-item.unlocked .badge-char-label {
  background: var(--pastel-yellow);
}

/* --- Celebration Overlay/Modal --- */
.celebration-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255, 249, 230, 0.95);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s;
}

.celebration-box {
  text-align: center;
  max-width: 480px;
  padding: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.celebration-confetti {
  font-size: 2.5rem;
  animation: bounce 1s infinite alternate;
}

.celebration-emoji {
  font-size: 9rem;
  background: #fff;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(255, 180, 128, 0.2);
  animation: pulseRotate 2s infinite ease-in-out;
}

.celebration-message {
  font-size: 2.3rem;
  font-weight: 900;
  color: #ff5b94;
}

.celebration-badge-alert {
  font-size: 1.15rem;
  font-weight: 700;
  color: #a39582;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-10px); }
}

@keyframes pulseRotate {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.08) rotate(5deg); }
}

/* Responsiveness for Mobile Devices (Smartphones & Tablets in portrait) */
@media (max-width: 768px) {
  body {
    padding: 0;
    overflow: hidden;
  }
  
  .game-container {
    width: 100vw;
    height: 100vh;
    height: -webkit-fill-available;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }

  .screen {
    padding: 15px;
    justify-content: space-between;
  }
  
  /* Menu Screen */
  .app-header {
    margin-bottom: 12px !important;
  }
  .app-logo {
    font-size: 2.2rem;
  }
  .app-subtitle {
    font-size: 1rem;
    margin-top: 4px;
  }
  .settings-panel {
    padding: 10px !important;
    margin-bottom: 12px !important;
    font-size: 0.9rem;
  }
  .settings-panel span {
    font-size: 0.95rem !important;
  }
  .menu-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .menu-card {
    padding: 14px 20px;
    flex-direction: row;
    text-align: left;
    gap: 12px;
    align-items: center;
  }
  .menu-card .card-icon {
    font-size: 2.8rem;
  }
  .menu-card h3 {
    font-size: 1.25rem;
  }
  .menu-card p {
    font-size: 0.9rem;
  }

  /* Game Header */
  .game-header {
    margin-bottom: 12px;
  }
  .game-title {
    font-size: 1.5rem;
  }
  .btn-icon {
    width: 48px;
    height: 48px;
  }
  .btn-voice-replay {
    width: 52px;
    height: 52px;
  }

  /* Quiz Mode */
  .quiz-content {
    gap: 15px;
  }
  .quiz-visual-box {
    flex-direction: column;
    gap: 12px;
  }
  .quiz-image {
    font-size: 5rem;
    width: 110px;
    height: 110px;
    border-radius: 20px;
  }
  .quiz-word-places {
    gap: 8px;
  }
  .char-slot {
    width: 54px;
    height: 54px;
    font-size: 2.2rem;
    border-radius: 12px;
  }
  .quiz-choices-box {
    gap: 10px;
    max-width: 100%;
  }
  .choice-card {
    width: 56px;
    height: 56px;
    font-size: 2.2rem;
    border-radius: 14px;
  }

  /* Trace Mode */
  .trace-content {
    gap: 12px;
  }
  .trace-select-btn {
    width: 48px;
    height: 48px;
    font-size: 1.3rem;
  }
  .canvas-outer-wrapper {
    flex-direction: column;
    gap: 15px;
    width: 100%;
  }
  .canvas-inner-box {
    width: 250px;
    height: 250px;
    border-radius: 24px;
    border-width: 4px;
  }
  .trace-guide-char {
    font-size: 9rem;
  }
  .trace-anim-container {
    width: 220px;
    height: 220px;
  }
  .canvas-controls {
    flex-direction: row;
    width: 100%;
    justify-content: center;
    gap: 10px;
  }
  .canvas-controls .btn-bubble {
    font-size: 0.95rem;
    padding: 10px 16px;
    border-radius: 14px;
  }

  /* Gallery Mode */
  .badge-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }
  .badge-item {
    font-size: 2rem;
    border-radius: 14px;
  }
  .badge-char-label {
    font-size: 0.75rem;
    bottom: 4px;
  }
}

@media (max-width: 380px) {
  /* Extra support for very small screens */
  .char-slot {
    width: 46px;
    height: 46px;
    font-size: 1.8rem;
  }
  .choice-card {
    width: 48px;
    height: 48px;
    font-size: 1.8rem;
  }
  .canvas-inner-box {
    width: 220px;
    height: 220px;
  }
  .trace-anim-container {
    width: 190px;
    height: 190px;
  }
  .badge-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.active-level {
  border: 4px solid var(--pastel-pink) !important;
  box-shadow: 0 0 10px rgba(255, 91, 148, 0.4) !important;
  transform: scale(1.05);
}

