:root {
  --bg: #0e0805;
  --surface: #1a1008;
  --surface2: #241508;
  --surface3: #2e1a0a;
  --gold: #c8952a;
  --gold2: #e8b84b;
  --gold3: #f5d27a;
  --red: #8b1a1a;
  --red2: #b52020;
  --cream: #f5ead0;
  --cream2: #e8d5a8;
  --muted: #8a6a3a;
  --border: #3a2010;
  --border2: #5a3520;
  --radius: 10px;
  --key-size: 72px;
}

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

body {
  background: var(--bg);
  color: var(--cream);
  font-family: 'Crimson Pro', serif;
  min-height: 100vh;
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(200,149,42,0.12) 0%, transparent 60%),
    radial-gradient(ellipse at 0% 100%, rgba(139,26,26,0.08) 0%, transparent 50%),
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23c8952a' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* ── HEADER ── */
header {
  text-align: center;
  padding: 20px 20px 14px;
  position: relative;
}
.temple-deco { display: none; }
.logo-monorom {
  display: block;
  width: auto;
  height: 110px;
  margin: 0 auto 8px;
  object-fit: contain;
  filter: drop-shadow(0 2px 12px rgba(200,149,42,0.25));
}
header h1 {
  font-family: 'Cinzel', serif;
  font-size: clamp(1.1rem, 3.5vw, 1.6rem);
  color: var(--gold2);
  letter-spacing: 3px;
  text-shadow: 0 0 30px rgba(200,149,42,0.4);
  margin-bottom: 2px;
}
header h1 span.brand-method {
  display: block;
  letter-spacing: 5px;
  color: var(--muted);
  font-style: italic;
  font-weight: 400;
  margin-top: 2px;
}
header p {
  font-size: 1rem;
  color: var(--muted);
  font-style: italic;
  letter-spacing: 1px;
}
.gold-line {
  width: 200px;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--gold), transparent);
  margin: 14px auto 0;
}

/* ── DISPLAY ZONE ── */
#display-zone {
  margin: 16px auto;
  max-width: 500px;
  padding: 0 16px;
}
.display-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 100px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 30px rgba(0,0,0,0.5), inset 0 1px 0 rgba(200,149,42,0.1);
}
.display-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(to right, transparent, var(--gold), transparent);
}
.char-big {
  font-size: 5rem;
  line-height: 1;
  color: var(--gold3);
  text-shadow: 0 0 20px rgba(200,149,42,0.5);
  min-width: 90px;
  text-align: center;
  transition: all 0.2s;
  font-family: 'Khmer', 'Noto Sans Khmer', sans-serif;
}
.char-big.pulse {
  animation: charPulse 0.3s ease;
}
@keyframes charPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); text-shadow: 0 0 40px rgba(200,149,42,0.8); }
  100% { transform: scale(1); }
}
.char-info { flex: 1; }
.char-name {
  font-family: 'Cinzel', serif;
  font-size: 1.1rem;
  color: var(--cream);
  margin-bottom: 4px;
}
.char-romanize {
  font-size: 1rem;
  color: var(--gold2);
  font-style: italic;
  margin-bottom: 4px;
}
.char-type {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.char-series {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.7rem;
  margin-top: 6px;
  font-family: 'Cinzel', serif;
}
.series-a { background: rgba(200,149,42,0.15); color: var(--gold2); border: 1px solid rgba(200,149,42,0.3); }
.series-o { background: rgba(139,26,26,0.2); color: #e87070; border: 1px solid rgba(139,26,26,0.4); }

.sound-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--red2));
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(200,149,42,0.3);
}
.sound-btn:hover { transform: scale(1.1); box-shadow: 0 4px 20px rgba(200,149,42,0.5); }
.sound-btn.playing { animation: soundPulse 0.6s ease infinite; }
@keyframes soundPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(200,149,42,0.4); }
  50% { box-shadow: 0 0 0 10px rgba(200,149,42,0); }
}

.idle-msg {
  color: var(--muted);
  font-style: italic;
  font-size: 1.2rem;
  text-align: center;
  width: 100%;
}

/* ── TABS ── */
.tabs {
  display: flex;
  max-width: 500px;
  margin: 0 auto 12px;
  padding: 0 16px;
  gap: 6px;
}
.tab {
  flex: 1;
  padding: 9px;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--muted);
  font-family: 'Crimson Pro', serif;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.tab.active {
  background: linear-gradient(135deg, var(--surface3), var(--surface2));
  border-color: var(--gold);
  color: var(--gold2);
}
.tab:hover { border-color: var(--border2); color: var(--cream2); }

/* ── KEYBOARD ── */
#keyboard {
  max-width: 500px;
  margin: 0 auto;
  padding: 0 12px 20px;
}

.section-label {
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  letter-spacing: 2px;
  color: var(--muted);
  text-transform: uppercase;
  margin: 12px 4px 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.keys-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.key {
  width: var(--key-size);
  height: var(--key-size);
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: all 0.15s;
  position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.04);
  user-select: none;
  -webkit-user-select: none;
}
.key:hover {
  border-color: var(--gold);
  background: var(--surface3);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.5), 0 0 12px rgba(200,149,42,0.2);
}
.key:active, .key.pressed {
  transform: translateY(1px) scale(0.96);
  background: var(--surface3);
  border-color: var(--gold2);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4), 0 0 20px rgba(200,149,42,0.3);
}

/* Corps de la consonne */
.key-body {
  font-size: 1.6rem;
  line-height: 1;
  color: var(--cream);
  font-family: 'Khmer', 'Noto Sans Khmer', sans-serif;
}
/* Pied de la consonne (coeng) */
.key-foot {
  font-size: 1rem;
  line-height: 1;
  color: var(--gold);
  font-family: 'Khmer', 'Noto Sans Khmer', sans-serif;
  border-top: 1px solid var(--border);
  padding-top: 2px;
  width: 100%;
  text-align: center;
}
/* Romanisation */
.key-roman {
  font-size: 1rem;
  color: var(--muted);
  font-family: 'Crimson Pro', serif;
  font-style: italic;
}

/* Série indicator */
.key.series-a .key-body { color: var(--cream); }
.key.series-o .key-body { color: #f0c0a0; }

/* Voyelles */
.key.vowel .key-body { color: var(--gold3); font-size: 1.8rem; }

/* Chiffres */
.key.number .key-body {
  font-size: clamp(0.7rem, 2.5vw, 1.4rem);
  color: var(--cream2);
  word-break: break-all;
  overflow: hidden;
  max-width: 100%;
  text-align: center;
  line-height: 1.1;
}
.key.number .key-roman {
  font-size: clamp(0.9rem, 1vw, 0.9rem);
  overflow: hidden;
  max-width: 100%;
  text-align: center;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.key.number {
  overflow: hidden;
  padding: 2px;
  height: auto;
  min-height: var(--key-size);
}

/* Spéciaux */
.key.special .key-body { font-size: 1.3rem; color: #a0d0e0; }
.key.wide {
  width: calc(var(--key-size) * 1.5 + 6px);
}

/* Shift button */
.shift-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 4px 6px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.shift-bar:hover { border-color: var(--gold); }
.shift-bar.active { border-color: var(--gold2); background: var(--surface3); }
.shift-label {
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  letter-spacing: 1px;
  color: var(--muted);
  text-transform: uppercase;
}
.shift-bar.active .shift-label { color: var(--gold2); }
.shift-icon {
  font-size: 1rem;
  color: var(--muted);
  transition: transform 0.2s;
}
.shift-bar.active .shift-icon { transform: rotate(180deg); color: var(--gold); }

/* ── FOOTER ── */
footer {
  text-align: center;
  padding: 16px;
  font-size: 1.1rem;
  color: var(--muted);
  font-style: italic;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

/* ── RESPONSIVE ── */
@media (max-width: 420px) {
  :root { --key-size: 60px; }
  .char-big { font-size: 3.8rem; min-width: 70px; }
}
@media (max-width: 350px) {
  :root { --key-size: 52px; }
}
