/* ============================================
   NIHONGO QUEST — style.css
   Modern Japanese aesthetic (wa-modern)
   ============================================ */

* { margin:0; padding:0; box-sizing:border-box; }

:root {
  --primary:  #3d3a8e;
  --sakura:   #e8637e;
  --gold:     #c9952e;
  --green:    #27ae60;
  --blue:     #2980b9;
  --purple:   #8e44ad;
  --red:      #c0392b;
  --text:     #2d3561;
  --text-light: #6b7280;
  --surface:  #ffffff;
  --border:   rgba(45,53,97,0.12);
  --shadow:   0 4px 20px rgba(45,53,97,0.1);
  --radius:   14px;
}

body {
  background: linear-gradient(160deg, #fff8f5 0%, #fdf0f7 50%, #f0f4ff 100%);
  color: var(--text);
  font-family: 'Poppins', 'Noto Sans JP', sans-serif;
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

.hidden { display: none !important; }

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fade-in {
  from { opacity:0; transform:translateY(14px); }
  to   { opacity:1; transform:translateY(0); }
}
@keyframes pop-in {
  0%   { transform:scale(0.85); opacity:0; }
  70%  { transform:scale(1.03); }
  100% { transform:scale(1);    opacity:1; }
}
@keyframes float {
  0%,100% { transform:translateY(0); }
  50%     { transform:translateY(-7px); }
}
@keyframes glow-grad {
  0%,100% { opacity:1; }
  50%     { opacity:0.75; }
}
@keyframes slide-up {
  from { transform:translateY(28px); opacity:0; }
  to   { transform:translateY(0);    opacity:1; }
}
@keyframes sakura-fall {
  0%   { transform:translateY(-20px) rotate(0deg);   opacity:1; }
  100% { transform:translateY(80px)  rotate(180deg); opacity:0; }
}
@keyframes steam {
  0%   { transform:translateY(0) scale(1);    opacity:0.55; }
  100% { transform:translateY(-30px) scale(1.5); opacity:0; }
}
@keyframes lu-pulse {
  0%,100% { box-shadow:0 0 30px rgba(201,149,46,0.25); }
  50%     { box-shadow:0 0 60px rgba(201,149,46,0.55), 0 0 100px rgba(232,99,126,0.2); }
}
@keyframes blink {
  0%,100% { opacity:1; }
  50%     { opacity:0; }
}

.blink-star { animation:float 2.2s ease-in-out infinite; font-size:2em; }
.blink-text { animation:blink 0.8s ease-in-out infinite; }

/* ============================================
   NAV BAR
   ============================================ */
#top-nav {
  width: 100%;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(45,53,97,0.09);
  padding: 7px 20px;
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-shrink: 0;
  z-index: 50;
}
.nav-link {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-light);
  text-decoration: none;
  padding: 4px 14px;
  border-radius: 20px;
  border: 1px solid rgba(45,53,97,0.13);
  transition: all 0.2s;
}
.nav-link:hover {
  color: var(--primary);
  background: rgba(61,58,142,0.06);
  border-color: rgba(61,58,142,0.28);
}

/* ============================================
   START SCREEN
   ============================================ */
#start-screen {
  width: 100%;
  max-width: 900px;
  height: calc(100vh - 38px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 28px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  scrollbar-width: thin;
  scrollbar-color: rgba(61,58,142,0.18) transparent;
}
#start-screen::-webkit-scrollbar { width:5px; }
#start-screen::-webkit-scrollbar-thumb { background:rgba(61,58,142,0.18); border-radius:4px; }

.title-wrap {
  display: flex;
  align-items: center;
  gap: 18px;
  animation: fade-in 0.5s ease-out;
}
#game-title {
  font-size: 2.8rem;
  font-weight: 800;
  text-align: center;
  line-height: 1.2;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #3d3a8e 0%, #e8637e 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: glow-grad 3s ease-in-out infinite;
}
.subtitle {
  font-size: 0.92rem;
  color: var(--text-light);
  text-align: center;
  animation: fade-in 0.7s ease-out;
}

/* Selection sections */
.sel-section {
  width: 100%;
  max-width: 820px;
  text-align: center;
  animation: fade-in 0.6s ease-out;
}
.sel-section h2 {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.sel-section h2::before,
.sel-section h2::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(61,58,142,0.15);
  max-width: 160px;
}

/* Character cards */
#char-select {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}
.char-card {
  cursor: pointer;
  border: 2px solid rgba(45,53,97,0.1);
  border-radius: 18px;
  padding: 16px 12px;
  background: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 120px;
  box-shadow: 0 2px 14px rgba(45,53,97,0.07);
  transition: all 0.22s ease;
}
.char-card:hover {
  border-color: rgba(61,58,142,0.3);
  box-shadow: 0 6px 24px rgba(61,58,142,0.14);
  transform: translateY(-4px);
}
.char-card.selected {
  border-color: var(--sakura);
  box-shadow: 0 6px 24px rgba(232,99,126,0.24);
  background: #fff5f8;
}
.char-card canvas {
  border-radius: 8px;
  width: 64px; height: 64px;
}
.cname { font-size: 0.72rem; font-weight: 700; color: var(--primary); }
.cdesc { font-size: 0.8rem; color: var(--text-light); }

/* Item cards */
#item-select {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.item-card {
  cursor: pointer;
  border: 2px solid rgba(45,53,97,0.1);
  border-radius: 18px;
  padding: 14px 10px;
  background: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  width: 130px;
  box-shadow: 0 2px 14px rgba(45,53,97,0.07);
  transition: all 0.22s ease;
}
.item-card:hover {
  border-color: rgba(61,58,142,0.3);
  box-shadow: 0 6px 24px rgba(61,58,142,0.14);
  transform: translateY(-4px);
}
.item-card.selected {
  border-color: var(--green);
  box-shadow: 0 6px 24px rgba(39,174,96,0.2);
  background: #f5fdf8;
}
.item-icon { font-size: 2.1rem; }
.iname { font-size: 0.72rem; font-weight: 700; color: var(--primary); }
.idesc { font-size: 0.7rem; color: var(--text-light); line-height: 1.6; text-align: center; }

/* Pixel button (repurposed as modern button) */
.pixel-btn {
  font-family: 'Poppins', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 12px 26px;
  background: linear-gradient(135deg, #e8637e, #c0304e);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  letter-spacing: 0.4px;
  box-shadow: 0 4px 16px rgba(232,99,126,0.35), 0 2px 4px rgba(0,0,0,0.07);
  transition: all 0.2s ease;
  text-transform: uppercase;
}
.pixel-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 26px rgba(232,99,126,0.44);
}
.pixel-btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 2px 8px rgba(232,99,126,0.28);
}
.pixel-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}
.item-btn {
  background: linear-gradient(135deg, #27ae60, #1a8a48);
  box-shadow: 0 4px 14px rgba(39,174,96,0.3);
  font-size: 0.78rem;
  padding: 10px 18px;
}
.item-btn:hover:not(:disabled) {
  box-shadow: 0 8px 24px rgba(39,174,96,0.4);
}

#btn-start { margin-top: 2px; font-size: 1rem; padding: 15px 38px; border-radius: 16px; }

.deco-row {
  font-size: 1.5rem;
  letter-spacing: 10px;
  margin-bottom: 4px;
  opacity: 0.65;
}

/* ============================================
   GAME SCREEN (MAP)
   ============================================ */
#game-screen {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
#map-hud {
  width: 800px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(45,53,97,0.1);
  border-top: none;
  padding: 6px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.76rem;
  gap: 8px;
}
#hud-left {
  color: var(--primary);
  font-weight: 600;
  min-width: 100px;
  flex-shrink: 0;
  line-height: 1.4;
}
.hud-active-lbl {
  font-size: 0.58rem;
  color: var(--text-light);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.hud-active-item {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold);
}

/* Grille légende + compteurs dans hud-right */
#hud-right {
  text-align: left !important;
}
.inv-legend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
}
.inv-leg {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border-radius: 7px;
  border: 1.5px solid rgba(45,53,97,0.12);
  background: rgba(255,255,255,0.8);
  cursor: pointer;
  font-size: 0.63rem;
  font-weight: 600;
  color: var(--primary);
  text-align: left;
  transition: all 0.15s;
  white-space: nowrap;
}
.inv-leg:hover:not(:disabled) {
  border-color: var(--gold);
  background: rgba(255,220,80,0.12);
}
.inv-leg.inv-leg-active {
  border-color: var(--gold);
  background: rgba(255,200,50,0.22);
  color: #7a5200;
  box-shadow: 0 0 0 1.5px rgba(255,190,40,0.35);
}
.inv-leg.inv-leg-empty {
  opacity: 0.38;
  cursor: not-allowed;
}
.inv-leg-icon { font-size: 0.85rem; }
.inv-leg-desc { flex: 1; }
.inv-leg-count {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--gold);
  margin-left: auto;
}
#hud-mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex: 1;
}
.hud-dir-label { font-size: 0.62rem; color: var(--text-light); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.hud-arrows    { font-size: 0.95rem; color: var(--primary); font-weight: 700; letter-spacing: 3px; }
#hud-right {
  color: var(--primary);
  min-width: 195px;
  text-align: right;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.55;
  flex-shrink: 0;
}
.legend-label { font-size: 0.6rem; color: var(--text-light); font-weight: 400; }
.hud-restart-btn {
  font-size: 0.6rem;
  padding: 3px 9px;
  background: white;
  color: var(--text-light);
  border: 1.5px solid rgba(107,114,128,0.35);
  box-shadow: none;
  border-radius: 7px;
  white-space: nowrap;
}
.hud-restart-btn:hover:not(:disabled) { background: rgba(107,114,128,0.07); box-shadow: none; }

/* ============================================
   WORKSHOP SCREEN
   ============================================ */
#workshop-screen {
  position: fixed;
  top:0; left:0;
  width: 100vw; height: 100vh;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  background: rgba(45,53,97,0.22);
  backdrop-filter: blur(8px);
}
#ws-room {
  width: 820px;
  min-height: 580px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  animation: pop-in 0.28s ease-out;
  background: white;
  border-radius: 22px;
  box-shadow: 0 24px 70px rgba(45,53,97,0.28);
  overflow: hidden;
}

/* Workshop themes — colored top border + tinted header */
.theme-temple #ws-room  { border-top: 5px solid var(--red); }
.theme-onsen  #ws-room  { border-top: 5px solid var(--blue); }
.theme-dojo   #ws-room  { border-top: 5px solid var(--green); }
.theme-garden #ws-room  { border-top: 5px solid var(--purple); }

.theme-temple #ws-header { background: linear-gradient(135deg, #fff6f6, #ffe4e4); }
.theme-onsen  #ws-header { background: linear-gradient(135deg, #f6f8ff, #e2eeff); }
.theme-dojo   #ws-header { background: linear-gradient(135deg, #f6fff9, #e2ffe9); }
.theme-garden #ws-header { background: linear-gradient(135deg, #faf6ff, #eddeff); }

.theme-temple #ws-kanji, .theme-temple #ws-name-label { color: var(--red); }
.theme-onsen  #ws-kanji, .theme-onsen  #ws-name-label { color: var(--blue); }
.theme-dojo   #ws-kanji, .theme-dojo   #ws-name-label { color: var(--green); }
.theme-garden #ws-kanji, .theme-garden #ws-name-label { color: var(--purple); }

.theme-temple #ws-lv-badge { background: var(--red);    color: white; }
.theme-onsen  #ws-lv-badge { background: var(--blue);   color: white; }
.theme-dojo   #ws-lv-badge { background: var(--green);  color: white; }
.theme-garden #ws-lv-badge { background: var(--purple); color: white; }

/* Workshop header */
#ws-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
}
#ws-title-area {
  display: flex;
  align-items: center;
  gap: 12px;
}
#ws-kanji {
  font-size: 2.2rem;
  font-weight: 700;
  font-family: 'Noto Sans JP', sans-serif;
}
#ws-name-label {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 1px;
}
#ws-desc-label {
  font-size: 0.78rem;
  color: var(--text-light);
}
#ws-subtitle {
  display: block;
  font-size: 0.7rem;
  color: var(--text-light);
  margin-top: 2px;
  line-height: 1.5;
}
#ws-lv-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 20px;
}
#btn-exit-ws {
  font-family: 'Poppins', sans-serif;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 6px 14px;
  background: transparent;
  color: #9ca3af;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: 12px;
}
#btn-exit-ws:hover {
  color: var(--red);
  border-color: #fca5a5;
  background: #fff5f5;
}

/* Decoration row */
#ws-deco {
  font-size: 1.6rem;
  letter-spacing: 14px;
  padding: 6px 0 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.65;
}

/* Exercise box */
#exo-box {
  width: 100%;
  padding: 20px 28px 24px;
  animation: slide-up 0.28s ease-out;
  flex: 1;
  display: flex;
  flex-direction: column;
}
#exo-instr {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
#exo-fr {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 18px;
  text-align: center;
  min-height: 22px;
  line-height: 1.6;
  background: linear-gradient(135deg, #fff8f5, #fdf5ff);
  border-radius: 12px;
  padding: 12px 20px;
  border: 1px solid rgba(45,53,97,0.07);
}
#exo-area {
  margin-bottom: 16px;
  min-height: 70px;
  flex: 1;
}

/* Text input (YAKU) */
#exo-area input[type="text"] {
  width: 100%;
  font-family: 'Noto Sans JP', 'Poppins', sans-serif;
  font-size: 1rem;
  padding: 12px 16px;
  background: white;
  color: var(--text);
  border: 2px solid rgba(45,53,97,0.15);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#exo-area input[type="text"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(61,58,142,0.1);
}

/* Word tiles (NARABE) */
.tile-bank, .tile-built {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 44px;
  padding: 10px;
  align-items: flex-start;
}
.tile-built {
  border: 2px dashed rgba(45,53,97,0.14);
  border-radius: 12px;
  margin-bottom: 12px;
  background: #f9fafb;
  min-height: 54px;
}
.tile-built-label {
  font-size: 0.7rem;
  color: var(--text-light);
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
}
.word-tile {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 14px;
  background: white;
  color: var(--primary);
  border: 2px solid rgba(61,58,142,0.18);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 2px 6px rgba(45,53,97,0.07);
}
.word-tile:hover  { background:rgba(61,58,142,0.05); border-color:var(--primary); transform:translateY(-2px); }
.word-tile.sel    { background:rgba(39,174,96,0.08);  border-color:var(--green);   color:var(--green); }
.word-tile.placed { background:rgba(142,68,173,0.08); border-color:var(--purple);  color:var(--purple); }
.word-tile.correct-tile { background:rgba(39,174,96,0.09);  border-color:var(--green);  color:#1a7a42;  cursor:default; }
.word-tile.wrong-tile   { background:rgba(231,76,60,0.07);  border-color:#e74c3c;        color:#b0321e;  cursor:default; }
.word-tile.disabled-tile { opacity:0.35; cursor:default; pointer-events:none; }

/* MCQ options (BUNPOU) */
.mcq-opts { display:flex; flex-direction:column; gap:10px; }
.mcq-opt {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 13px 18px;
  background: white;
  color: var(--text);
  border: 2px solid rgba(45,53,97,0.1);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  line-height: 1.6;
  box-shadow: 0 2px 6px rgba(45,53,97,0.05);
}
.mcq-opt:hover   { background:rgba(61,58,142,0.04); border-color:rgba(61,58,142,0.28); transform:translateX(4px); }
.mcq-opt.sel     { background:rgba(61,58,142,0.06); border-color:var(--primary); }
.mcq-opt.correct-opt { background:rgba(39,174,96,0.08);  border-color:var(--green); color:#1a7a42; }
.mcq-opt.wrong-opt   { background:rgba(231,76,60,0.06);  border-color:#e74c3c;      color:#b0321e; }
.mcq-opt.elim        { opacity:0.28; cursor:default; pointer-events:none; }

/* ============================================
   JOSHI — PARTICULES
   ============================================ */
.joshi-sentence {
  text-align: center;
  font-size: 1.1rem;
  font-family: 'Noto Sans JP', sans-serif;
  color: var(--text);
  margin-bottom: 22px;
  line-height: 2.5;
  letter-spacing: 1px;
  font-weight: 500;
}
.joshi-pre, .joshi-post { color: var(--text); }
.joshi-blank {
  display: inline-block;
  min-width: 50px;
  padding: 3px 12px;
  margin: 0 6px;
  background: #f3f4f6;
  border: 2px solid rgba(45,53,97,0.18);
  border-radius: 8px;
  color: #9ca3af;
  text-align: center;
  vertical-align: middle;
  transition: all 0.15s;
  font-weight: 700;
}
.joshi-blank.blank-selected { border-color:var(--gold);   color:var(--gold);   background:#fefbf0; }
.joshi-blank.blank-correct  { border-color:var(--green);  color:var(--green);  background:#f0fdf5; }
.joshi-blank.blank-wrong    { border-color:#e74c3c;        color:#e74c3c;       background:#fff5f5; }

.particle-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.particle-btn {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  padding: 12px 20px;
  min-width: 70px;
  background: white;
  color: var(--primary);
  border: 2px solid rgba(61,58,142,0.18);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  box-shadow: 0 2px 8px rgba(45,53,97,0.08);
}
.particle-btn:hover { background:rgba(61,58,142,0.04); border-color:var(--primary); transform:translateY(-2px); box-shadow:0 4px 14px rgba(45,53,97,0.14); }
.particle-btn.p-sel     { background:rgba(201,149,46,0.08); border-color:var(--gold);   color:var(--gold);   box-shadow:0 0 0 3px rgba(201,149,46,0.15); }
.particle-btn.p-correct { background:rgba(39,174,96,0.08);  border-color:var(--green);  color:var(--green);  cursor:default; }
.particle-btn.p-wrong   { background:rgba(231,76,60,0.06);  border-color:#e74c3c;        color:#e74c3c;       cursor:default; }
.particle-btn.p-dim     { opacity:0.3; cursor:default; }

.particle-hint-line {
  font-size: 0.78rem;
  color: var(--text-light);
  text-align: center;
  margin-top: 8px;
  font-style: italic;
}

/* Feedback */
#exo-feedback {
  min-height: 36px;
  font-size: 0.85rem;
  text-align: center;
  margin-bottom: 14px;
  line-height: 1.8;
  padding: 10px 16px;
  border-radius: 10px;
  border: 2px solid transparent;
  color: var(--text-light);
  transition: all 0.2s;
  font-weight: 500;
}
#exo-feedback.wrong {
  color: #b0321e;
  border-color: rgba(231,76,60,0.28);
  background: rgba(231,76,60,0.06);
}
#exo-feedback.correct {
  color: #1a7a42;
  border-color: rgba(39,174,96,0.28);
  background: rgba(39,174,96,0.06);
}
#exo-feedback .correction {
  display: block;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 1.15em;
  font-weight: 700;
  color: var(--primary);
  margin-top: 6px;
  line-height: 1.8;
  letter-spacing: 1px;
  word-break: break-all;
}

/* Button row */
#exo-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

/* Progress */
#exo-progress {
  font-size: 0.74rem;
  color: var(--text-light);
  text-align: center;
}

/* ============================================
   CONFIRM MODAL
   ============================================ */
#confirm-modal {
  position: fixed;
  top:0; left:0;
  width: 100vw; height: 100vh;
  z-index: 500;
  background: rgba(45,53,97,0.38);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
}
#confirm-box {
  background: white;
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(45,53,97,0.3);
  padding: 36px 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  animation: pop-in 0.24s ease-out;
  max-width: 420px;
  text-align: center;
}
#confirm-icon { font-size: 2.6rem; }
#confirm-msg {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.7;
  font-weight: 500;
}
#confirm-btns {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}
.confirm-yes-btn {
  background: linear-gradient(135deg, #e74c3c, #c0302a);
  box-shadow: 0 4px 14px rgba(231,76,60,0.3);
}
.confirm-yes-btn:hover:not(:disabled) { box-shadow: 0 8px 24px rgba(231,76,60,0.42); }
.confirm-no-btn {
  background: linear-gradient(135deg, #27ae60, #1a8a48);
  box-shadow: 0 4px 14px rgba(39,174,96,0.3);
}
.confirm-no-btn:hover:not(:disabled) { box-shadow: 0 8px 24px rgba(39,174,96,0.42); }

/* ============================================
   LEVEL UP SCREEN
   ============================================ */
#levelup-screen {
  position: fixed;
  top:0; left:0;
  width: 100vw; height: 100vh;
  z-index: 200;
  background: rgba(45,53,97,0.48);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.35s ease-out;
}
#lu-box {
  text-align: center;
  border-radius: 24px;
  padding: 48px 56px;
  background: white;
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
  animation: lu-pulse 2.5s ease-in-out infinite, pop-in 0.4s ease-out;
}
.lu-stars {
  font-size: 1.4rem;
  animation: float 1.8s ease-in-out infinite;
}
#lu-title {
  font-size: 1.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--sakura));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
#lu-detail { font-size: 0.9rem; color: var(--text); line-height: 1.8; font-weight: 500; }
.lu-deco   { font-size: 2rem; letter-spacing: 14px; }

/* ============================================
   STEAM / SAKURA PARTICLES
   ============================================ */
.steam-p {
  position: absolute;
  font-size: 1.2em;
  animation: steam 2s ease-out infinite;
  opacity: 0.5;
  pointer-events: none;
}
.steam-p:nth-child(1) { left:10%; animation-delay:0s; }
.steam-p:nth-child(2) { left:30%; animation-delay:0.7s; }
.steam-p:nth-child(3) { left:60%; animation-delay:1.4s; }
.steam-p:nth-child(4) { left:80%; animation-delay:0.3s; }

.sakura-p {
  position: absolute;
  font-size: 1em;
  animation: sakura-fall 3s ease-in infinite;
  pointer-events: none;
}
.sakura-p:nth-child(1) { left:5%;  animation-delay:0s;   animation-duration:2.8s; }
.sakura-p:nth-child(2) { left:25%; animation-delay:0.8s; animation-duration:3.2s; }
.sakura-p:nth-child(3) { left:50%; animation-delay:1.5s; animation-duration:2.5s; }
.sakura-p:nth-child(4) { left:70%; animation-delay:0.4s; animation-duration:3.5s; }
.sakura-p:nth-child(5) { left:90%; animation-delay:2s;   animation-duration:2.9s; }

/* ============================================
   LOGIN SCREEN
   ============================================ */
#login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 20px 16px 30px;
  width: 100%;
  max-width: 520px;
  overflow-y: auto;
  max-height: 100vh;
}
#login-box {
  width: 100%;
  background: rgba(255,255,255,0.95);
  border: 2px solid rgba(61,58,142,0.18);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.auth-sep {
  font-size: 0.72rem;
  color: var(--text-light);
  margin: 4px 0;
}
.auth-guest-btn {
  font-size: 0.78rem;
  background: white;
  color: var(--text);
  border: 2px solid rgba(61,58,142,0.25);
  box-shadow: none;
  padding: 8px 20px;
}
.auth-guest-btn:hover:not(:disabled) {
  background: rgba(61,58,142,0.04);
  box-shadow: none;
}
.auth-guest-note {
  font-size: 0.65rem;
  color: var(--text-light);
  text-align: center;
  margin-top: -4px;
}

/* ============================================
   PLAYER INFO BAR (start-screen)
   ============================================ */
#player-info-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.85);
  border: 1.5px solid rgba(61,58,142,0.14);
  border-radius: 10px;
  padding: 6px 14px;
  font-size: 0.78rem;
  color: var(--text);
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  max-width: 500px;
}
#auth-name-disp {
  font-weight: 700;
  color: var(--primary);
}

/* Title smaller on start-screen */
.title-wrap-sm { gap: 8px; margin: 4px 0 0; }
.game-title-sm {
  font-family: 'Noto Sans JP', 'Poppins', sans-serif;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(135deg, var(--primary), var(--sakura));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============================================
   AUTH (shared inputs/buttons)
   ============================================ */
.auth-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--primary);
  text-transform: uppercase;
  margin-bottom: 10px;
}
.auth-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  justify-content: center;
}
.auth-input {
  border: 2px solid rgba(61,58,142,0.22);
  border-radius: 8px;
  padding: 7px 12px;
  font-family: 'Poppins', sans-serif;
  font-size: 0.82rem;
  outline: none;
  flex: 1;
  min-width: 110px;
  color: var(--text);
  transition: border-color 0.2s;
}
.auth-input:focus { border-color: var(--primary); }
.auth-btn {
  font-size: 0.72rem;
  padding: 7px 16px;
  border-radius: 8px;
}
.auth-reg-btn {
  background: white;
  color: var(--primary);
  border: 2px solid var(--primary);
  box-shadow: none;
}
.auth-reg-btn:hover:not(:disabled) {
  background: rgba(61,58,142,0.06);
  box-shadow: none;
}
.auth-out-btn {
  background: white;
  color: var(--text-light);
  border: 2px solid rgba(107,114,128,0.4);
  box-shadow: none;
  font-size: 0.68rem;
  padding: 5px 12px;
}
.auth-out-btn:hover:not(:disabled) { background: rgba(107,114,128,0.06); box-shadow: none; }
.auth-logged {
  font-size: 0.85rem;
  color: var(--text);
}
#auth-msg {
  font-size: 0.74rem;
  color: var(--red);
  min-height: 16px;
  text-align: center;
}
#auth-sync {
  font-size: 0.7rem;
  color: var(--green);
  margin-left: 10px;
}

/* ============================================
   D-PAD TACTILE
   ============================================ */
#dpad {
  display: none; /* masqué par défaut, affiché sur écrans tactiles */
  position: absolute;
  bottom: 56px;
  left: 16px;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 52px);
  gap: 4px;
  z-index: 50;
}
/* Visible uniquement sur écrans tactiles */
@media (hover: none), (pointer: coarse) {
  #dpad { display: grid; }
}

.dpad-btn {
  width: 52px;
  height: 52px;
  background: rgba(45, 53, 97, 0.75);
  border: 2px solid rgba(255,255,255,0.35);
  border-radius: 10px;
  color: #fff;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  backdrop-filter: blur(4px);
  transition: background 0.1s;
}
.dpad-btn:active, .dpad-btn.pressed {
  background: rgba(200, 80, 60, 0.85);
}

/* Placement dans la grille 3×2 */
#dpad-up     { grid-column: 2; grid-row: 1; }
#dpad-left   { grid-column: 1; grid-row: 2; }
#dpad-center { grid-column: 2; grid-row: 2; background: rgba(45,53,97,0.3); pointer-events: none; }
#dpad-right  { grid-column: 3; grid-row: 2; }
#dpad-down   { grid-column: 2; grid-row: 3; }

/* ============================================
   RESPONSIVE — CANVAS + HUD
   ============================================ */

/* Le canvas et le HUD s'adaptent à la largeur */
#mapCanvas {
  display: block;
  border: 2px solid rgba(45,53,97,0.18);
  box-shadow: 0 8px 40px rgba(45,53,97,0.18);
  max-width: 100%;
  height: auto;
}

/* Tablette (≤ 860px) */
@media (max-width: 860px) {
  #mapCanvas { width: 100vw; height: auto; }
  #map-hud {
    width: 100vw;
    padding: 5px 10px;
    gap: 6px;
  }
  #hud-left  { min-width: 90px; font-size: 0.7rem; }
  #hud-right { min-width: 160px; font-size: 0.6rem; text-align: left; }
  .hud-arrows { font-size: 0.85rem; letter-spacing: 2px; }
  #ws-room { width: 95vw; min-height: unset; }
}

/* Mobile (≤ 560px) */
@media (max-width: 560px) {
  body { overflow-y: auto; }
  #mapCanvas { width: 100vw; height: auto; }
  #map-hud {
    width: 100vw;
    flex-wrap: wrap;
    justify-content: center;
    padding: 6px 8px;
    gap: 4px;
  }
  #hud-left  { min-width: unset; font-size: 0.72rem; order: 1; }
  #hud-mid   { order: 3; width: 100%; flex-direction: row; gap: 8px; justify-content: center; align-items: center; }
  #hud-right { order: 2; text-align: left; min-width: unset; font-size: 0.6rem; }
  .legend-label { display: none; }
  #ws-room { width: 100vw; border-radius: 0; }
  #ws-header { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
  #ws-kanji { font-size: 1.6rem; }
  #ws-name-label { font-size: 0.9rem; }
  #exo-box { padding: 12px 14px 16px; }
  #exo-fr { font-size: 0.9rem; padding: 10px 14px; }
  .mcq-opt { font-size: 0.82rem; padding: 10px 14px; }
  .word-tile { font-size: 0.8rem; padding: 6px 10px; }
  .particle-btn { font-size: 1rem; padding: 10px 14px; min-width: 54px; }
  #lu-box { padding: 28px 20px; }
  #confirm-box { padding: 24px 20px; }

  /* Login / start screens */
  #login-screen { padding: 14px 12px 20px; }
  #start-screen { padding: 10px 12px; }
  .char-card canvas { width: 48px !important; height: 48px !important; }
  #btn-start { font-size: 0.8rem; padding: 10px 20px; }
}

/* ============================================
   VOCABULAIRE PANEL (YAKU lv2+)
   ============================================ */
.vocab-inline {
  margin-bottom: 10px;
  width: 100%;
}
.vocab-inline-btn {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1.5px solid rgba(45,53,97,0.2);
  background: rgba(255,255,255,0.85);
  color: var(--primary);
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 5px;
}
.vocab-inline-btn:hover {
  border-color: var(--gold);
  background: rgba(255,220,80,0.1);
}
.vocab-inline-list {
  display: none;
  flex-wrap: wrap;
  gap: 5px 10px;
  background: rgba(255,252,240,0.97);
  border: 1.5px solid rgba(45,53,97,0.1);
  border-radius: 10px;
  padding: 8px 12px;
}
.vocab-inline-list.open {
  display: flex;
}
.vocab-entry {
  font-size: 0.68rem;
  color: var(--primary);
  white-space: nowrap;
}
.vocab-entry b {
  color: #7a4000;
}
