/* ==========================================================================
   style.css — dark basement chrome around the canvas
   ========================================================================== */
* {
  margin: 0; padding: 0; box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

html, body {
  width: 100%; height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  background: #070503;
  overflow: hidden;
  font-family: "Trebuchet MS", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #e8dcc0;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  touch-action: none;
  position: relative;
}

body {
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 50% 40%, #241a10 0%, #0b0704 62%, #030201 100%);
}

#stage {
  position: absolute;
  left: 50%; top: 50%;
  width: 900px; height: 540px;
  transform-origin: center center;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 3px #1d1409, 0 0 42px 8px rgba(0,0,0,0.9), 0 0 120px 20px rgba(120,20,20,0.09);
  border-radius: 3px;
  overflow: hidden;
}

#game {
  display: block;
  width: 900px; height: 540px;
  image-rendering: auto;
  background: #0a0705;
}

/* ---------------- overlay screens ---------------- */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: space-between;
  padding: 30px 24px 24px;
  text-align: center;
  z-index: 5;
}
.screen.hidden { display: none !important; }

#screen-dead, #screen-win, #screen-pause {
  justify-content: center;
  gap: 14px;
  background: rgba(6, 3, 2, 0.55);
  backdrop-filter: blur(2px);
}

.title-block { margin-top: 8px; }

.game-title {
  font-size: 62px; letter-spacing: 9px; font-weight: 900;
  background: linear-gradient(180deg, #f4e3bd 0%, #d8b077 45%, #8f2020 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 0 #170d08) drop-shadow(0 0 22px rgba(180,30,30,0.45));
  line-height: 1;
}
.game-sub {
  margin-top: 8px; font-size: 17px; letter-spacing: 7px; color: #a99772;
  text-shadow: 0 2px 0 #150c07;
}

.game-tagline {
  margin-top: 5px; font-size: 13px; letter-spacing: 3px; color: #ffd95a;
  text-transform: uppercase; opacity: 0.88;
}

.title-foot { display: flex; flex-direction: column; align-items: center; gap: 10px; }

.dead-title, .win-title, .pause-title, .mastery-title {
  font-size: 50px; font-weight: 900; letter-spacing: 8px;
  filter: drop-shadow(0 4px 0 #170d08);
}
.dead-title { color: #c8302e; text-shadow: 0 0 30px rgba(200,40,40,0.5); }
.win-title  { color: #ffd95a; text-shadow: 0 0 30px rgba(255,215,90,0.45); }
.mastery-title { color: #4ee085; text-shadow: 0 0 30px rgba(78,224,133,0.45); }
.pause-title { color: #e8dcc0; }
.dead-sub, .mastery-sub { font-size: 15px; color: #b3a181; letter-spacing: 2px; }
.mastery-stars { font-size: 34px; letter-spacing: 6px; margin: 4px 0; }

.stat-grid {
  display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 10px 14px; margin-top: 6px;
}
.stat-cell {
  background: rgba(14, 9, 5, 0.78);
  border: 2px solid rgba(220, 200, 160, 0.2);
  border-radius: 7px;
  padding: 9px 14px 10px;
  min-width: 130px;
}
.stat-cell .k { display: block; font-size: 11px; letter-spacing: 2px; color: #9d8c6c; }
.stat-cell .v { display: block; font-size: 25px; font-weight: 800; color: #f2e4c4; line-height: 1.15; }
.stat-cell.hl .v { color: #ffd95a; }

.item-recap {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
  max-width: 660px; font-size: 11.5px; color: #b8a680;
}
.item-recap span {
  border: 1px solid rgba(220,200,160,0.22);
  background: rgba(14,9,5,0.6);
  border-radius: 4px; padding: 3px 7px;
}
.item-recap .none { border: none; background: none; color: #7a6d55; }

.btn {
  font-family: inherit; font-size: 18px; font-weight: 800; letter-spacing: 4px;
  color: #f4e6c4; cursor: pointer;
  padding: 11px 30px;
  background: linear-gradient(180deg, #59401f 0%, #3a2712 100%);
  border: 3px solid #191009;
  border-radius: 6px;
  box-shadow: inset 0 2px 0 rgba(255,225,170,0.25), 0 5px 0 #191009, 0 8px 18px rgba(0,0,0,0.6);
  transition: transform .07s, box-shadow .07s, filter .12s;
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
.btn:hover { filter: brightness(1.16); }
.btn:active { transform: translateY(4px); box-shadow: inset 0 2px 0 rgba(255,225,170,0.2), 0 1px 0 #191009; }

.btn-gold {
  background: linear-gradient(180deg, #9c6c19 0%, #684107 100%);
  color: #fff4d1;
  border-color: #3b2404;
  box-shadow: inset 0 2px 0 rgba(255,240,180,0.4), 0 5px 0 #2b1700, 0 8px 22px rgba(255,180,30,0.25);
}
.btn-quick {
  background: linear-gradient(180deg, #443425 0%, #281d14 100%);
  font-size: 15px; padding: 8px 22px;
}
.btn-back {
  font-family: inherit; font-size: 14px; font-weight: 700; color: #d8c095;
  background: rgba(30,20,10,0.8); border: 1px solid rgba(220,200,160,0.3);
  border-radius: 4px; padding: 6px 14px; cursor: pointer;
}

.hint { font-size: 12px; color: #9b8a6b; letter-spacing: 1px; }
.hint b { color: #e2cf9f; }

/* ---------------- In-Game Word Bar HUD ---------------- */
#word-bar {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 14px;
  width: max-content;
  max-width: calc(100% - 24px);
  box-sizing: border-box;
  background: rgba(14, 9, 6, 0.94);
  border: 2px solid rgba(226, 207, 159, 0.4);
  border-radius: 12px;
  padding: 7px 16px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.8), inset 0 1px 0 rgba(255,255,255,0.14);
  z-index: 25;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.25s ease-out, transform 0.25s ease-out, visibility 0.25s ease-out;
}
#word-bar.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-50%) translateY(12px);
}

.word-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.word-icon { font-size: 22px; line-height: 1; }
.word-zh { font-size: 17px; font-weight: 800; color: #ffd95a; text-shadow: 0 1px 2px #000; }
.word-ipa { font-size: 13px; color: #a89674; font-family: monospace; }

.icon-btn {
  background: rgba(40, 26, 14, 0.9);
  border: 1px solid rgba(220, 200, 160, 0.35);
  border-radius: 6px;
  color: #f1dfae;
  font-size: 15px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .08s, background .1s;
}
.icon-btn:hover { background: rgba(70, 48, 26, 0.9); transform: scale(1.08); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn.speaking {
  background: rgba(255, 217, 90, 0.4);
  border-color: #ffd95a;
  box-shadow: 0 0 12px rgba(255, 217, 90, 0.8);
  transform: scale(1.15);
}

.word-slots {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  flex-shrink: 1;
  min-width: 0;
}
.word-slot {
  width: 36px;
  height: 40px;
  border-radius: 6px;
  background: rgba(26, 17, 10, 0.95);
  border: 2px solid #5a4227;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  font-weight: 900;
  color: #796041;
  text-transform: lowercase;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.6);
  transition: all .12s ease;
  flex-shrink: 0;
  box-sizing: border-box;
}
.word-slot.active {
  border-color: #ffd95a;
  box-shadow: 0 0 10px rgba(255, 217, 90, 0.4), inset 0 0 8px rgba(255, 217, 90, 0.2);
  animation: slotPulse 1.2s infinite ease-in-out;
}
.word-slot.filled {
  border-color: #4ee085;
  background: linear-gradient(180deg, #1b3d22 0%, #102615 100%);
  color: #a4ffc5;
  text-shadow: 0 0 8px rgba(78, 224, 133, 0.6);
}
@keyframes slotPulse {
  0%, 100% { border-color: #ffd95a; transform: scale(1); }
  50% { border-color: #fff2a3; transform: scale(1.06); }
}

/* Dynamic density tiers so word bar banner border expands cleanly without clipping long words */
#word-bar.len-compact { gap: 10px; padding: 6px 14px; }
#word-bar.len-compact .word-slots { gap: 4px; }
#word-bar.len-compact .word-slot { width: 30px; height: 36px; font-size: 18px; border-radius: 5px; }

#word-bar.len-dense { gap: 8px; padding: 5px 12px; }
#word-bar.len-dense .word-slots { gap: 3px; }
#word-bar.len-dense .word-slot { width: 25px; height: 32px; font-size: 15px; border-radius: 4px; border-width: 1.5px; }

#word-bar.len-tiny { gap: 6px; padding: 5px 10px; }
#word-bar.len-tiny .word-slots { gap: 2.5px; }
#word-bar.len-tiny .word-slot { width: 21px; height: 28px; font-size: 13px; border-radius: 4px; border-width: 1.5px; }

.unit-badge {
  font-size: 11px;
  letter-spacing: 1px;
  color: #8c7959;
  border-left: 1px solid rgba(220,200,160,0.2);
  padding-left: 12px;
}

/* ---------------- Course / Unit Selector Screen ---------------- */
/* ---------------- Title Screen Mastery Banner & Buttons ---------------- */
.mastery-banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(36, 60, 28, 0.85);
  border: 1px solid #4ee085;
  border-radius: 20px;
  padding: 6px 16px;
  margin-top: 8px;
  color: #bdfad2;
  font-size: 13px;
  box-shadow: 0 0 16px rgba(78, 224, 133, 0.25);
  animation: pulse-glow 3s infinite ease-in-out;
}
.mb-star { font-size: 16px; }
.mb-text b { color: #ffd95a; }

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 12px rgba(78, 224, 133, 0.2); }
  50% { box-shadow: 0 0 22px rgba(78, 224, 133, 0.45); }
}

.btn-mastery {
  background: linear-gradient(180deg, #2b6134 0%, #16381c 100%);
  border-color: #4ee085;
  color: #c9ffdc;
  box-shadow: 0 0 14px rgba(78, 224, 133, 0.25);
}
.btn-mastery:hover {
  background: linear-gradient(180deg, #377d43 0%, #1d4d26 100%);
  border-color: #6effa2;
  color: #ffffff;
  box-shadow: 0 0 20px rgba(78, 224, 133, 0.45);
}
.btn-mastery-sm {
  padding: 6px 14px;
  font-size: 13px;
  background: linear-gradient(180deg, #2b6134 0%, #16381c 100%);
  border-color: #4ee085;
  color: #c9ffdc;
}

/* ---------------- Course / Unit Selector Screen (Master-Detail) ---------------- */
#screen-curriculum {
  padding: 12px 16px;
  justify-content: flex-start;
  gap: 8px;
  background: radial-gradient(circle at 50% 10%, #1c130d 0%, #0d0805 100%);
  z-index: 15;
  box-sizing: border-box;
  overflow: hidden;
}
.curr-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 217, 90, 0.15);
  padding-bottom: 6px;
  flex-shrink: 0;
}
.curr-title {
  font-size: 20px;
  font-weight: 800;
  color: #ffd95a;
  letter-spacing: 2px;
  text-shadow: 0 2px 10px rgba(255, 217, 90, 0.2);
}

.curr-body {
  width: 100%;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Left Column: Sidebar & Book Shelf */
.curr-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: hidden;
  background: rgba(18, 12, 7, 0.7);
  border: 1px solid rgba(220, 200, 160, 0.15);
  border-radius: 8px;
  padding: 8px;
  box-sizing: border-box;
}

.grade-pill-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  flex-shrink: 0;
}

.grade-pill {
  background: rgba(28, 18, 11, 0.9);
  border: 1px solid rgba(220, 200, 160, 0.2);
  color: #b8a680;
  border-radius: 5px;
  padding: 5px 2px;
  font-size: 11px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all .12s ease;
}
.grade-pill:hover {
  border-color: rgba(255, 217, 90, 0.5);
  color: #fff0be;
}
.grade-pill.active {
  background: linear-gradient(180deg, #593814 0%, #331f0a 100%);
  border-color: #ffd95a;
  color: #fff0be;
  box-shadow: 0 0 8px rgba(255, 217, 90, 0.25);
}

.curr-book-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  flex: 1;
  padding-right: 2px;
  scrollbar-width: thin;
}

.book-card-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: rgba(26, 17, 10, 0.85);
  border: 1.5px solid rgba(220, 200, 160, 0.18);
  border-radius: 6px;
  cursor: pointer;
  transition: all .12s ease;
  text-align: left;
}
.book-card-item:hover {
  border-color: rgba(255, 217, 90, 0.5);
  background: rgba(38, 25, 15, 0.9);
  transform: translateX(2px);
}
.book-card-item.active {
  background: linear-gradient(90deg, #442a12 0%, #26170a 100%);
  border-color: #ffd95a;
  box-shadow: 0 0 10px rgba(255, 217, 90, 0.22);
}
.bci-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.bci-icon {
  font-size: 18px;
  flex-shrink: 0;
}
.bci-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.bci-name {
  font-size: 13px;
  font-weight: 700;
  color: #f5e6c8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bci-sub {
  font-size: 10px;
  color: #a69472;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bci-badge {
  font-size: 10px;
  background: rgba(78, 224, 133, 0.18);
  color: #6effa2;
  border: 1px solid rgba(78, 224, 133, 0.35);
  border-radius: 10px;
  padding: 1px 6px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Right Column: Main Content & Unit Grid */
.curr-main {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: hidden;
}

.curr-active-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(22, 14, 8, 0.85);
  border: 1px solid rgba(255, 217, 90, 0.2);
  border-radius: 8px;
  padding: 6px 12px;
  flex-shrink: 0;
}
.curr-active-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}
.curr-active-icon {
  font-size: 22px;
}
.curr-active-title {
  font-size: 15px;
  font-weight: 800;
  color: #ffd95a;
  margin: 0;
}
.curr-active-sub {
  font-size: 11px;
  color: #a69472;
  margin: 0;
}

.curr-mastery-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #b8a680;
  background: rgba(28, 18, 11, 0.85);
  padding: 4px 10px;
  border-radius: 5px;
  border: 1px solid rgba(220, 200, 160, 0.18);
}
.curr-mastery-pill b {
  color: #4ee085;
}

.unit-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  width: 100%;
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
  scrollbar-width: thin;
}
.unit-card {
  background: rgba(22, 14, 8, 0.92);
  border: 1.5px solid rgba(220, 200, 160, 0.2);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 4px;
  cursor: pointer;
  position: relative;
  transition: transform .1s ease, border-color .1s ease, box-shadow .1s ease;
}
.unit-card:hover {
  transform: translateY(-2px);
  border-color: #ffd95a;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6);
}
.unit-card-badge {
  display: inline-block;
  background: rgba(78, 224, 133, 0.18);
  color: #6effa2;
  border: 1px solid rgba(78, 224, 133, 0.4);
  font-size: 9.5px;
  font-weight: 800;
  border-radius: 4px;
  padding: 1px 6px;
}
.unit-card-icon { font-size: 20px; line-height: 1; }
.unit-card-title { font-size: 14px; font-weight: 800; color: #f2e4c4; }
.unit-card-theme { font-size: 11.5px; color: #a69472; }
.unit-card-words { font-size: 10.5px; color: #9a886a; line-height: 1.3; }
.unit-card-stars { font-size: 12px; letter-spacing: 2px; }

/* Review section special capstone styling */
.unit-card.review-card {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, rgba(48, 32, 14, 0.95) 0%, rgba(26, 17, 8, 0.96) 100%);
  border: 2px solid #ffd95a;
  box-shadow: 0 0 16px rgba(255, 217, 90, 0.22);
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  text-align: left;
}
.review-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.review-icon {
  font-size: 28px;
}
.review-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.review-info .unit-card-badge {
  background: rgba(255, 217, 90, 0.2);
  color: #ffd95a;
  border-color: rgba(255, 217, 90, 0.5);
  font-size: 10.5px;
  width: fit-content;
}
.review-info .unit-card-title {
  font-size: 15px;
  color: #fff0be;
}
.review-info .unit-card-theme {
  font-size: 11.5px;
  color: #ffd95a;
}
.review-info .unit-card-words {
  font-size: 11px;
  color: #cfbc97;
}
.review-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.btn-gold-sm {
  background: linear-gradient(180deg, #d69e2e 0%, #975a16 100%);
  color: #fff8db;
  border: 1px solid #ffd95a;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  transition: all .1s ease;
}
.btn-gold-sm:hover {
  background: linear-gradient(180deg, #e6b042 0%, #b36e1c 100%);
  transform: scale(1.04);
}

/* ---------------- Complete Mastery Lexicon Modal ---------------- */
.lexicon-box {
  position: relative;
  z-index: 2;
  width: 860px;
  max-width: 95vw;
  height: 500px;
  max-height: 92vh;
  background: linear-gradient(180deg, #18120c 0%, #0d0805 100%);
  border: 3px solid #8e682d;
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 0 40px rgba(0,0,0,0.95), 0 0 50px rgba(78,224,133,0.15);
}
.lexicon-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid rgba(220, 200, 160, 0.18);
  padding-bottom: 8px;
}
.lexicon-title {
  font-size: 20px;
  font-weight: 900;
  color: #ffd95a;
  letter-spacing: 1px;
}
.lexicon-sub {
  font-size: 12px;
  color: #bca984;
  margin-top: 2px;
}
.lexicon-close {
  background: transparent;
  border: 1px solid rgba(220, 200, 160, 0.3);
  color: #ffd95a;
  font-size: 16px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .1s ease;
}
.lexicon-close:hover {
  background: #501b1b;
  border-color: #ff8888;
  color: #fff;
}
.lexicon-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.lexicon-filters {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
  max-width: 100%;
}
.l-filter-btn {
  flex: 0 0 auto;
  white-space: nowrap;
  background: rgba(30, 20, 12, 0.85);
  border: 1px solid rgba(220, 200, 160, 0.25);
  color: #b8a680;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: all .12s ease;
}
.l-filter-btn:hover {
  border-color: rgba(78, 224, 133, 0.6);
  color: #fff;
}
.l-filter-btn.active {
  background: linear-gradient(180deg, #2b6134 0%, #16381c 100%);
  border-color: #4ee085;
  color: #c9ffdc;
  box-shadow: 0 0 10px rgba(78, 224, 133, 0.3);
}
.lexicon-search-wrap {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}
.lexicon-search-input {
  width: 100%;
  background: rgba(14, 9, 6, 0.9);
  border: 1px solid rgba(220, 200, 160, 0.3);
  border-radius: 6px;
  padding: 5px 10px;
  color: #fff0be;
  font-family: inherit;
  font-size: 12px;
  outline: none;
}
.lexicon-search-input:focus {
  border-color: #ffd95a;
  box-shadow: 0 0 8px rgba(255, 217, 90, 0.25);
}

.lexicon-word-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 8px;
  overflow-y: auto;
  padding: 4px 2px 10px;
}
.lexicon-card {
  background: rgba(24, 16, 10, 0.85);
  border: 1px solid rgba(220, 200, 160, 0.2);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  transition: all .1s ease;
}
.lexicon-card:hover {
  border-color: #4ee085;
  background: rgba(28, 22, 12, 0.95);
  transform: translateY(-1px);
}
.lc-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.lc-icon { font-size: 20px; line-height: 1; }
.lc-badge {
  font-size: 10px;
  background: rgba(78, 224, 133, 0.18);
  color: #6effa2;
  border-radius: 3px;
  padding: 1px 4px;
  font-weight: 700;
}
.lc-word-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.lc-word {
  font-size: 15px;
  font-weight: 800;
  color: #ffd95a;
  letter-spacing: 0.5px;
}
.lc-ipa {
  font-size: 11px;
  color: #a39274;
}
.lc-zh {
  font-size: 13px;
  color: #e5d7ba;
  font-weight: 700;
}
.lc-meta {
  font-size: 10.5px;
  color: #8c7b60;
  display: flex;
  justify-content: space-between;
}
.lc-buff {
  font-size: 10.5px;
  color: #4ee085;
  background: rgba(78, 224, 133, 0.08);
  padding: 2px 4px;
  border-radius: 3px;
}
.lc-actions {
  display: flex;
  gap: 4px;
  margin-top: 2px;
}
.lc-btn {
  flex: 1;
  padding: 3px 6px;
  font-size: 11px;
  font-family: inherit;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid rgba(220, 200, 160, 0.25);
  background: rgba(30, 20, 12, 0.85);
  color: #d1c1a1;
  transition: all .1s ease;
}
.lc-btn:hover {
  background: #3e2a18;
  color: #fff;
  border-color: #ffd95a;
}
.lc-btn-play {
  background: linear-gradient(180deg, #422d14 0%, #291807 100%);
  border-color: #c9933e;
  color: #ffd95a;
}
.lc-btn-play:hover {
  background: linear-gradient(180deg, #60421e 0%, #3d240b 100%);
  border-color: #ffd95a;
}

/* ---------------- Roguelike 3-Choice Reward Modal ---------------- */
.modal {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal.hidden { display: none; }

.reward-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 2, 1, 0.85);
  backdrop-filter: blur(4px);
}
.reward-box {
  position: relative;
  z-index: 2;
  width: 840px;
  background: linear-gradient(180deg, #1f140a 0%, #100a05 100%);
  border: 3px solid #8e682d;
  border-radius: 14px;
  padding: 24px 28px;
  box-shadow: 0 0 40px rgba(0,0,0,0.9), 0 0 60px rgba(255,190,40,0.15);
  text-align: center;
}
.reward-header { margin-bottom: 18px; }
.reward-badge {
  display: inline-block;
  background: #501b1b;
  color: #ff9d9d;
  border: 1px solid #943232;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  padding: 2px 10px;
  margin-bottom: 6px;
}
.reward-title {
  font-size: 26px;
  font-weight: 900;
  color: #ffd95a;
  letter-spacing: 3px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}
.reward-sub { font-size: 13px; color: #bca984; letter-spacing: 1px; margin-top: 4px; }

.reward-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.reward-card {
  background: linear-gradient(180deg, #2b1d10 0%, #160e07 100%);
  border: 2px solid #6b4e28;
  border-radius: 10px;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  min-height: 210px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,0.7), inset 0 1px 0 rgba(255,255,255,0.1);
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.reward-card:hover {
  transform: translateY(-5px) scale(1.02);
  border-color: #ffd95a;
  box-shadow: 0 8px 24px rgba(255,217,90,0.25), inset 0 0 14px rgba(255,217,90,0.15);
}
.reward-card:active {
  transform: scale(0.97);
}
.reward-card.synergy {
  border-color: #9d3ee0;
  background: linear-gradient(180deg, #321842 0%, #170a20 100%);
}
.reward-card.synergy:hover {
  border-color: #d18aff;
  box-shadow: 0 8px 24px rgba(180,80,255,0.35);
}
.card-tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 2px 7px;
  border-radius: 3px;
  background: rgba(0,0,0,0.4);
  color: #d5be93;
}
.card-icon { font-size: 38px; margin: 8px 0; }
.card-name { font-size: 16px; font-weight: 800; color: #f4e8cc; line-height: 1.2; }
.card-desc { font-size: 12px; color: #bda881; margin-top: 6px; line-height: 1.3; }
.card-action {
  margin-top: 10px;
  width: 100%;
  font-size: 12px;
  font-weight: 800;
  padding: 6px 0;
  border-radius: 4px;
  background: rgba(255,255,255,0.08);
  color: #ffd95a;
  border: 1px solid rgba(255,217,90,0.3);
}

/* ---------------- mobile touch controls ---------------- */
#touch-ui {
  position: fixed; inset: 0; z-index: 20; pointer-events: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
#touch-ui * {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#touch-ui.hidden { display: none; }

.fs-btn {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(20, 13, 7, 0.65);
  border: 1px solid rgba(226, 207, 159, 0.35);
  color: #e8dcc0;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 30;
  pointer-events: auto;
  backdrop-filter: blur(4px);
  transition: background 0.2s, transform 0.1s;
  outline: none;
}
.fs-btn:active {
  transform: scale(0.92);
  background: rgba(50, 30, 15, 0.85);
  border-color: #ffd95a;
  color: #ffd95a;
}

#joystick {
  position: fixed;
  left: calc(22px + env(safe-area-inset-left, 0px));
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  width: 138px; height: 138px; border-radius: 50%;
  background: radial-gradient(circle, rgba(60,44,26,0.5) 0%, rgba(20,13,7,0.42) 70%);
  border: 3px solid rgba(226, 207, 159, 0.3);
  pointer-events: auto;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
#joy-knob {
  position: absolute; left: 50%; top: 50%;
  width: 58px; height: 58px; margin: -29px 0 0 -29px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #cbb68b, #6f5934);
  border: 3px solid #1a1109;
  box-shadow: 0 3px 10px rgba(0,0,0,0.7);
  pointer-events: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

#shoot-pad {
  position: fixed;
  right: calc(20px + env(safe-area-inset-right, 0px));
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  width: 168px; height: 168px;
  pointer-events: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.sbtn {
  position: absolute;
  width: 58px; height: 58px;
  font-size: 21px; line-height: 1; color: rgba(241, 223, 174, 0.82);
  font-family: inherit;
  background: radial-gradient(circle at 40% 32%, rgba(160, 44, 44, 0.38), rgba(70, 16, 16, 0.44));
  border: 2px solid rgba(226, 207, 159, 0.4);
  border-radius: 50%;
  box-shadow: inset 0 1px 2px rgba(255, 200, 180, 0.18), 0 3px 8px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0.55;
  pointer-events: auto;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  outline: none;
  transition: opacity 0.12s ease, transform 0.08s ease, filter 0.08s ease, background 0.12s ease;
}
.sbtn.on, .sbtn:active {
  opacity: 0.95;
  filter: brightness(1.4);
  transform: scale(0.92);
  background: radial-gradient(circle at 40% 32%, rgba(210, 50, 50, 0.82), rgba(110, 20, 20, 0.88));
  border-color: rgba(255, 220, 120, 0.8);
  color: #fff6d8;
}
#sb-up    { left: 55px; top: 0; }
#sb-down  { left: 55px; bottom: 0; }
#sb-left  { left: 0; top: 55px; }
#sb-right { right: 0; top: 55px; }

#rotate-hint {
  display: none;
  position: fixed; left: 0; right: 0;
  bottom: calc(196px + env(safe-area-inset-bottom, 0px));
  align-items: center; justify-content: center; gap: 8px;
  font-size: 12.5px; letter-spacing: 1px; color: #9b8a6b;
  z-index: 15; pointer-events: none;
}
#rotate-hint .ph {
  display: inline-block; width: 13px; height: 20px;
  border: 2px solid #9b8a6b; border-radius: 3px;
  animation: tilt 2.4s ease-in-out infinite;
}
@keyframes tilt {
  0%, 45% { transform: rotate(0deg); }
  60%, 90% { transform: rotate(-90deg); }
  100% { transform: rotate(0deg); }
}

/* portrait phones: nudge the player towards landscape */
@media (max-aspect-ratio: 1/1) {
  #rotate-hint { display: flex; }
}

/* ==========================================================================
   Player Auth & Cloud Sync Game Widget Styles
   ========================================================================== */
.game-auth-bar {
  position: absolute;
  top: 14px;
  right: 18px;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-auth-trigger {
  background: rgba(30, 22, 16, 0.85);
  border: 2px solid #b8860b;
  color: #ffd700;
  padding: 6px 14px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-auth-trigger:hover {
  background: #3b2814;
  border-color: #ffd700;
  transform: translateY(-1px);
}

.player-auth-pill {
  background: rgba(20, 15, 10, 0.9);
  border: 2px solid #5a4225;
  border-radius: 20px;
  padding: 4px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.6);
}

.player-avatar {
  font-size: 14px;
}

.player-name {
  color: #f1ebd9;
  font-weight: bold;
  font-size: 12px;
}

.cloud-badge {
  font-size: 10px;
  color: #34d399;
  background: rgba(16, 185, 129, 0.15);
  padding: 2px 6px;
  border-radius: 10px;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.admin-link-badge {
  font-size: 10px;
  color: #818cf8;
  background: rgba(99, 102, 241, 0.18);
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid rgba(99, 102, 241, 0.4);
  text-decoration: none;
  font-weight: bold;
  transition: all 0.15s ease;
}

.admin-link-badge:hover {
  background: rgba(99, 102, 241, 0.35);
  color: #fff;
}

.btn-auth-logout {
  background: none;
  border: none;
  color: #a8947e;
  cursor: pointer;
  font-size: 12px;
  padding: 0 2px;
  transition: color 0.15s;
}

.btn-auth-logout:hover {
  color: #ff5555;
}

/* Auth Modal */
.game-auth-modal {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(4px);
  z-index: 120;
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.game-auth-modal.active {
  display: flex;
}

.auth-modal-card {
  background: #1c140d;
  border: 3px solid #8b6508;
  box-shadow: 0 0 25px rgba(0,0,0,0.8), inset 0 0 15px rgba(0,0,0,0.5);
  border-radius: 12px;
  width: 90%;
  max-width: 380px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  color: #f1ebd9;
}

.auth-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #3d2b15;
  padding-bottom: 12px;
}

.auth-tabs {
  display: flex;
  gap: 8px;
}

.auth-tab {
  background: none;
  border: none;
  color: #8c785f;
  font-family: inherit;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  padding: 4px 8px;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.auth-tab.active {
  color: #ffd700;
  border-bottom-color: #ffd700;
}

.auth-close-btn {
  background: none;
  border: none;
  color: #8c785f;
  font-size: 16px;
  cursor: pointer;
}

.auth-close-btn:hover {
  color: #ff5555;
}

.auth-alert {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 11px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.auth-field label {
  font-size: 11px;
  color: #bfa888;
  font-weight: bold;
}

.auth-input {
  background: #0d0905;
  border: 2px solid #5a4225;
  border-radius: 6px;
  color: #fff;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.auth-input:focus {
  border-color: #ffd700;
}

.btn-auth-submit {
  background: linear-gradient(180deg, #b8860b, #7d5a03);
  border: 2px solid #ffd700;
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: bold;
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 6px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
  transition: all 0.15s ease;
}

.btn-auth-submit:hover {
  background: linear-gradient(180deg, #d49b0d, #946c05);
  transform: translateY(-1px);
}
