/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background:
    radial-gradient(ellipse 120% 80% at 30% 0%, rgba(255,235,180,0.5), transparent 60%),
    radial-gradient(ellipse 90% 70% at 80% 100%, rgba(120,70,30,0.25), transparent 60%),
    radial-gradient(circle at 50% 50%, #ece1c4 0%, #dcc99e 60%, #c8b07c 100%);
  color: #3a2614;
  font-family: 'Shippori Mincho', 'Noto Serif JP', serif;
  font-size: 13px;
  overflow: hidden;
  height: 100vh;
}

/* ===== Layout ===== */
#wrapper {
  display: grid;
  grid-template-columns: 1fr 260px;
  grid-template-rows: auto auto 1fr;
  height: 100vh;
  max-width: 1100px;
  min-width: 800px;
  margin: 0 auto;
  gap: 6px;
  padding: 6px;
}

/* ===== Title Strip ===== */
#title-strip {
  grid-column: 1 / 3;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 4px 12px 3px;
  background: rgba(122,29,29,0.06);
  border: 1px solid rgba(163,129,45,0.4);
  border-radius: 1px;
  box-shadow: inset 0 1px 0 rgba(255,250,230,0.5);
}
.title-strip-lat {
  font-family: 'Cinzel', serif;
  font-size: 11px;
  font-weight: 700;
  color: #7a1d1d;
  letter-spacing: 0.35em;
  white-space: nowrap;
}
.title-strip-jp {
  font-family: 'Shippori Mincho', serif;
  font-size: 10px;
  color: #5b4023;
  letter-spacing: 0.2em;
  white-space: nowrap;
}
.title-ornament { flex-shrink: 0; }

/* ===== Top HUD ===== */
#top-hud {
  grid-column: 1 / 3;
  grid-row: 2;
  background: rgba(236,225,196,0.92);
  border: 1px solid #a3812d;
  border-radius: 2px;
  box-shadow: 0 2px 8px rgba(58,38,20,0.15), inset 0 1px 0 rgba(255,250,230,0.7);
  display: flex;
  align-items: center;
  padding: 7px 12px;
  gap: 12px;
  min-width: 0;
  overflow: visible;
  position: relative;
  z-index: 10;
}

#player-block {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

/* RANK バッジ */
#rank-badge {
  display: flex;
  align-items: center;
  gap: 3px;
  background: #7a1d1d;
  border: 1px solid #a3812d;
  padding: 3px 8px 3px 6px;
  font-family: 'Cinzel', serif;
  font-size: 8px;
  color: #cba24a;
  letter-spacing: 0.15em;
  white-space: nowrap;
  flex-shrink: 0;
}
#rank-badge strong {
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  color: #cba24a;
  font-family: 'Cinzel', serif;
  letter-spacing: 0;
}

.name-lat {
  font-family: 'Cinzel', serif;
  font-size: 9px;
  color: #5b4023;
  letter-spacing: 0.15em;
  white-space: nowrap;
}

#player-name-hud {
  font-family: 'Shippori Mincho', serif;
  font-size: 14px;
  font-weight: 700;
  color: #3a2614;
  white-space: nowrap;
}

.level-badge {
  background: rgba(58,38,20,0.07);
  border: 1px solid rgba(163,129,45,0.5);
  padding: 2px 7px;
  font-family: 'Cinzel', serif;
  font-size: 10px;
  color: #5b4023;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.bar-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.bar-label {
  font-family: 'Cinzel', serif;
  font-size: 8px;
  color: #5b4023;
  letter-spacing: 0.05em;
  width: 24px;
  line-height: 1.2;
  text-align: right;
}

.lat-s {
  display: block;
  font-size: 7px;
  color: #a3812d;
  letter-spacing: 0.08em;
}

.comp-label {
  font-family: 'Shippori Mincho', serif;
  font-size: 9px;
  width: 26px;
}
.comp-ern  { color: #2a4a6a; }
.comp-saria { color: #5a2a6a; }

.bar-bg {
  width: 75px;
  height: 8px;
  background: rgba(58,38,20,0.12);
  overflow: hidden;
  border: 1px solid rgba(163,129,45,0.3);
}

.bar {
  height: 100%;
  transition: width 0.3s ease;
}

.hp-fill    { background: linear-gradient(90deg, #8b1a1a, #c43030); }
.exp-fill   { background: linear-gradient(90deg, #6e521a, #a3812d); }
.comp0-fill { background: linear-gradient(90deg, #1a3a5a, #3a7aaa); }
.comp1-fill { background: linear-gradient(90deg, #3a1a5a, #7a3aaa); }

.bar-text {
  font-family: 'Cinzel', serif;
  font-size: 9px;
  color: #5b4023;
  white-space: nowrap;
  letter-spacing: 0.04em;
}

#time-block {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.time-item {
  font-family: 'Cinzel', serif;
  font-size: 10px;
  color: #5b4023;
  white-space: nowrap;
  letter-spacing: 0.08em;
}

.boss-timer { color: #7a1d1d; font-weight: 700; }

.speed-btn {
  background: rgba(58,38,20,0.07);
  border: 1px solid rgba(163,129,45,0.5);
  color: #5b4023;
  padding: 3px 9px;
  font-family: 'Cinzel', serif;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  letter-spacing: 0.08em;
}
.speed-btn:hover  { background: rgba(58,38,20,0.14); color: #3a2614; }
.speed-btn.active { background: #7a1d1d; border-color: #a3812d; color: #cba24a; }

#stat-block {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}

.stat-item {
  font-family: 'Cinzel', serif;
  font-size: 10px;
  color: #5b4023;
  white-space: nowrap;
  letter-spacing: 0.05em;
}

/* ===== Main area ===== */
#main-area {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  grid-row: 3;
  grid-column: 1;
}

/* Game wrap with corner ornaments */
#game-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.panel-corner {
  position: absolute;
  width: 16px;
  height: 16px;
  z-index: 2;
  pointer-events: none;
}
.panel-corner--tl { top: 0; left: 0; }
.panel-corner--tr { top: 0; right: 0; }
.panel-corner--bl { bottom: 0; left: 0; }
.panel-corner--br { bottom: 0; right: 0; }

#game-container {
  width: 100%;
  height: 100%;
  border: 1px solid #a3812d;
  overflow: hidden;
  background: rgba(210,190,150,0.25);
  box-shadow: inset 0 0 24px rgba(58,38,20,0.08);
}

#game-container canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

/* CHRONICA — 戦闘ログ */
#battle-log {
  height: 130px;
  background: rgba(236,225,196,0.85);
  border: 1px solid #a3812d;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px 3px;
  border-bottom: 1px solid rgba(163,129,45,0.4);
  flex-shrink: 0;
  background: rgba(220,200,160,0.4);
}

.log-header-title {
  font-family: 'Cinzel', serif;
  font-size: 9px;
  color: #7a1d1d;
  letter-spacing: 0.3em;
  font-weight: 700;
}

.log-header-sub {
  font-family: 'Shippori Mincho', serif;
  font-size: 10px;
  color: #5b4023;
}

#log-inner {
  display: flex;
  flex-direction: column-reverse;
  padding: 5px 10px;
  flex: 1;
  overflow-y: auto;
}

.log-entry {
  font-family: 'Shippori Mincho', serif;
  font-size: 11px;
  line-height: 1.6;
  padding: 1px 0;
  border-bottom: 1px solid rgba(163,129,45,0.12);
  color: #5b4023;
}

.log-entry.highlight { color: #7a1d1d; font-weight: 600; }
.log-entry.danger    { color: #8b1a1a; }
.log-entry.success   { color: #2a5a38; }
.log-entry.rare      { color: #1a3a6a; }
.log-entry.legendary { color: #7a5a0a; font-weight: 600; }

/* ===== Side panel ===== */
#side-panel {
  background: rgba(236,225,196,0.9);
  border: 1px solid #a3812d;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  grid-column: 2;
  grid-row: 2 / 4;
  box-shadow: 0 2px 8px rgba(58,38,20,0.1);
  position: relative;
}

/* ===== Tabs ===== */
#panel-tabs {
  display: flex;
  flex-wrap: wrap;
  border-bottom: 1px solid #a3812d;
  background: rgba(210,190,150,0.5);
  flex-shrink: 0;
}

.tab-btn {
  flex: 1 0 calc(100% / 3);
  min-width: 0;
  padding: 5px 2px;
  background: none;
  border: none;
  color: #5b4023;
  cursor: pointer;
  font-family: 'Shippori Mincho', serif;
  font-size: 11px;
  line-height: 1.2;
  transition: all 0.15s;
  border-bottom: 2px solid transparent;
}

.tab-btn:hover {
  color: #3a2614;
  background: rgba(58,38,20,0.06);
}

.tab-btn.active {
  color: #7a1d1d;
  border-bottom: 2px solid #7a1d1d;
  background: rgba(122,29,29,0.05);
  font-weight: 700;
}

.tab-lat {
  display: block;
  font-family: 'Cinzel', serif;
  font-size: 7px;
  letter-spacing: 0.1em;
  color: #a3812d;
  margin-top: 1px;
}

.tab-btn.active .tab-lat { color: #7a1d1d; }

.tab-content { display: none; padding: 10px; overflow-y: auto; flex: 1; }
.tab-content.active { display: block; }

/* ===== Section titles ===== */
.section-title {
  font-family: 'Cinzel', serif;
  font-size: 9px;
  color: #7a1d1d;
  letter-spacing: 0.25em;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(163,129,45,0.4);
  padding-bottom: 4px;
}

/* ===== Equipment ===== */
.equip-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: rgba(255,250,230,0.5);
  border: 1px solid rgba(163,129,45,0.3);
  margin-bottom: 4px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.equip-slot:hover { border-color: #a3812d; background: rgba(255,250,230,0.8); }
.slot-icon { font-size: 14px; }
.slot-name {
  font-family: 'Cinzel', serif;
  font-size: 9px;
  color: #5b4023;
  width: 30px;
  letter-spacing: 0.08em;
}
.slot-item {
  font-family: 'Shippori Mincho', serif;
  font-size: 12px;
  color: #3a2614;
  flex: 1;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-family: 'Shippori Mincho', serif;
  font-size: 11px;
  color: #5b4023;
  border-bottom: 1px solid rgba(163,129,45,0.1);
}
.stat-row span { color: #3a2614; font-weight: 600; }

/* ===== Inventory ===== */
.inv-group-header {
  font-family: 'Cinzel', serif;
  font-size: 9px;
  font-weight: 600;
  color: #7a1d1d;
  background: rgba(210,190,150,0.4);
  border-top: 1px solid rgba(163,129,45,0.3);
  border-bottom: 1px solid rgba(163,129,45,0.3);
  padding: 4px 8px;
  margin: 6px 0 3px;
  letter-spacing: 0.15em;
}
.inv-group-header:first-child { margin-top: 0; }
.inv-group-count { color: #a3812d; font-weight: 400; }

.inv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  background: rgba(255,250,230,0.4);
  border: 1px solid rgba(163,129,45,0.22);
  margin-bottom: 2px;
  cursor: pointer;
  transition: border-color 0.15s;
  position: relative;
}
.inv-item:hover { border-color: #a3812d; background: rgba(255,250,230,0.7); }
.inv-item.inv-equipped { border-color: #7a1d1d; background: rgba(122,29,29,0.04); }

.inv-item-icon  { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
.inv-item-body  { flex: 1; min-width: 0; }
.inv-item-name  { font-family: 'Shippori Mincho', serif; font-size: 12px; color: #3a2614; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inv-item-stats { font-family: 'Cinzel', serif; font-size: 9px; color: #5b4023; margin-top: 1px; letter-spacing: 0.05em; }
.inv-equipped-mark {
  font-family: 'Cinzel', serif;
  font-size: 8px;
  color: #7a1d1d;
  background: rgba(122,29,29,0.08);
  border: 1px solid rgba(122,29,29,0.3);
  padding: 1px 4px;
  flex-shrink: 0;
  letter-spacing: 0.08em;
}
.inv-item-type { font-family: 'Cinzel', serif; font-size: 9px; color: #5b4023; letter-spacing: 0.08em; }

.rarity-common    { color: #5b4023; }
.rarity-uncommon  { color: #2a5a38; }
.rarity-rare      { color: #1a3a6a; }
.rarity-legendary { color: #7a5a0a; font-weight: 700; }

/* ===== Quests ===== */
.quest-card {
  background: rgba(255,250,230,0.5);
  border: 1px solid rgba(163,129,45,0.3);
  padding: 8px;
  margin-bottom: 6px;
  font-size: 12px;
}
.quest-title    { font-family: 'Shippori Mincho', serif; color: #7a1d1d; font-weight: 700; margin-bottom: 4px; }
.quest-desc     { font-family: 'Shippori Mincho', serif; color: #5b4023; margin-bottom: 4px; }
.quest-progress { font-family: 'Cinzel', serif; color: #1a3a6a; font-size: 10px; letter-spacing: 0.05em; }
.quest-reward   { font-family: 'Cinzel', serif; color: #2a5a38; font-size: 10px; margin-top: 4px; }
.quest-done     { border-color: rgba(163,129,45,0.12); opacity: 0.6; }

/* ===== Muted text ===== */
.muted-text {
  font-family: 'Shippori Mincho', serif;
  font-size: 11px;
  color: #7a6040;
  line-height: 1.6;
  min-height: 16px;
}
.bio-text { font-style: italic; }

/* ===== Guild nav links ===== */
.guild-nav-link {
  display: block;
  margin: 8px 0 2px;
  padding: 7px 0;
  background: rgba(122,29,29,0.06);
  border: 1px solid rgba(163,129,45,0.45);
  color: #7a1d1d;
  font-family: 'Cinzel', serif;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  letter-spacing: 0.1em;
  transition: all 0.15s;
}
.guild-nav-link:hover {
  background: rgba(122,29,29,0.12);
  border-color: #a3812d;
  color: #5b1010;
}
.guild-nav-link--equip {
  background: rgba(110,82,26,0.06);
  color: #5b4023;
  margin-top: 3px;
}
.guild-nav-link--equip:hover {
  background: rgba(110,82,26,0.14);
  color: #3a2614;
}

/* ===== Guild tab ===== */
#guild-display-name {
  font-family: 'Shippori Mincho', serif;
  font-size: 14px;
  font-weight: 700;
  color: #7a1d1d;
  padding: 8px;
  background: rgba(255,250,230,0.5);
  border: 1px solid rgba(163,129,45,0.3);
  margin-bottom: 8px;
}
#guild-bonus-text { font-family: 'Shippori Mincho', serif; font-size: 12px; color: #2a5a38; margin-bottom: 4px; }
.guild-stat-row {
  display: flex;
  justify-content: space-between;
  font-family: 'Shippori Mincho', serif;
  font-size: 11px;
  padding: 2px 0;
  color: #5b4023;
}

/* ===== Multiplayer ===== */
.multi-status { padding: 6px 10px; font-family: 'Shippori Mincho', serif; font-size: 12px; margin-bottom: 8px; }
.multi-status.online  { background: rgba(42,90,56,0.08); border: 1px solid rgba(42,90,56,0.35); color: #2a5a38; }
.multi-status.offline { background: rgba(122,29,29,0.06); border: 1px solid rgba(122,29,29,0.25); color: #7a1d1d; }

#passphrase-input {
  width: 100%;
  padding: 8px 10px;
  background: rgba(255,250,230,0.6);
  border: 1px solid rgba(163,129,45,0.4);
  color: #3a2614;
  font-family: 'Shippori Mincho', serif;
  font-size: 13px;
  margin-bottom: 6px;
}
#passphrase-input:focus { outline: none; border-color: #a3812d; }
.multi-hint { font-family: 'Shippori Mincho', serif; font-size: 10px; color: #5b4023; margin-top: 10px; line-height: 1.5; }
#partner-info { background: rgba(255,250,230,0.5); border: 1px solid rgba(163,129,45,0.3); padding: 8px; font-family: 'Shippori Mincho', serif; font-size: 12px; }

/* ===== Buttons ===== */
.btn {
  width: 100%;
  padding: 8px;
  border: none;
  cursor: pointer;
  font-family: 'Shippori Mincho', serif;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
  transition: all 0.15s;
  letter-spacing: 0.05em;
}
.btn-primary { background: #7a1d1d; border: 1px solid #a3812d; color: #cba24a; }
.btn-primary:hover { background: #8b2020; }
.btn-danger  { background: rgba(122,29,29,0.08); border: 1px solid rgba(122,29,29,0.4); color: #7a1d1d; }
.btn-gold    { background: rgba(163,129,45,0.1); border: 1px solid #a3812d; color: #6e521a; }
.btn-gold:hover { background: rgba(163,129,45,0.2); }
.btn-sell    { background: rgba(110,82,26,0.1); border: 1px solid rgba(163,129,45,0.5); color: #6e521a; }
.btn-sell:hover { background: rgba(110,82,26,0.2); }
.btn-unlock {
  background: rgba(58,38,20,0.06);
  border: 1px solid rgba(163,129,45,0.4);
  color: #5b4023;
  font-family: 'Cinzel', serif;
  font-size: 10px;
  padding: 3px 10px;
  margin-left: 8px;
  cursor: pointer;
  letter-spacing: 0.08em;
}
.btn-unlock:hover { background: rgba(58,38,20,0.12); }

.item-modal-equipped {
  display: flex;
  align-items: center;
  color: #2a5a38;
  font-family: 'Cinzel', serif;
  font-size: 10px;
  margin-bottom: 4px;
  letter-spacing: 0.1em;
}

/* ===== Modals ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(58,38,20,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.modal-box {
  background: radial-gradient(circle at 50% 30%, #ece1c4 0%, #dcc99e 100%);
  border: 2px solid #a3812d;
  padding: 28px 24px;
  min-width: 320px;
  max-width: 500px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(58,38,20,0.4), inset 0 0 30px rgba(58,38,20,0.06);
}
.modal-box.small { min-width: 280px; }

.modal-title {
  font-family: 'Cinzel', serif;
  font-size: 18px;
  font-weight: 700;
  color: #7a1d1d;
  margin-bottom: 6px;
  letter-spacing: 0.15em;
}

.modal-subtitle {
  font-family: 'Shippori Mincho', serif;
  font-size: 13px;
  color: #5b4023;
  margin-bottom: 16px;
}

#hero-name-input {
  width: 100%;
  padding: 10px;
  background: rgba(255,250,230,0.7);
  border: 1px solid #a3812d;
  color: #3a2614;
  font-family: 'Shippori Mincho', serif;
  font-size: 16px;
  text-align: center;
  margin-bottom: 12px;
}
#hero-name-input:focus { outline: none; border-color: #6e521a; }

/* ===== Guild Choice ===== */
.guild-choice-list { display: flex; gap: 12px; margin-top: 12px; justify-content: center; flex-wrap: wrap; }
.guild-choice-card {
  background: rgba(255,250,230,0.6);
  border: 1px solid rgba(163,129,45,0.4);
  padding: 14px;
  width: 140px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}
.guild-choice-card:hover { border-color: #a3812d; background: rgba(255,250,230,0.9); transform: translateY(-2px); }
.guild-choice-card.warriors { border-color: rgba(122,29,29,0.4); }
.guild-choice-card.warriors:hover { border-color: #7a1d1d; }
.guild-choice-card.mages   { border-color: rgba(26,58,106,0.4); }
.guild-choice-card.mages:hover { border-color: #1a3a6a; }
.guild-choice-card.thieves { border-color: rgba(42,90,56,0.4); }
.guild-choice-card.thieves:hover { border-color: #2a5a38; }
.guild-card-title { font-family: 'Shippori Mincho', serif; font-size: 13px; font-weight: 700; color: #7a1d1d; margin-bottom: 6px; }
.guild-card-desc  { font-family: 'Shippori Mincho', serif; font-size: 10px; color: #5b4023; line-height: 1.5; }
.guild-card-bonus { font-family: 'Shippori Mincho', serif; font-size: 10px; color: #2a5a38; margin-top: 6px; }

/* ===== Item actions ===== */
.item-actions { display: flex; gap: 6px; margin-top: 6px; }
.item-equip-btn {
  padding: 3px 8px;
  font-family: 'Cinzel', serif;
  font-size: 10px;
  border: 1px solid rgba(163,129,45,0.4);
  background: rgba(255,250,230,0.6);
  color: #5b4023;
  cursor: pointer;
  letter-spacing: 0.08em;
}
.item-equip-btn:hover { background: rgba(122,29,29,0.08); border-color: #7a1d1d; color: #7a1d1d; }

/* ===== Shop ===== */
#shop-filter-row { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.shop-filter-btn {
  background: rgba(255,250,230,0.5);
  border: 1px solid rgba(163,129,45,0.3);
  color: #5b4023;
  padding: 2px 8px;
  font-family: 'Cinzel', serif;
  font-size: 9px;
  cursor: pointer;
  letter-spacing: 0.08em;
}
.shop-filter-btn.active { background: #7a1d1d; border-color: #a3812d; color: #cba24a; }

#shop-list { overflow-y: auto; max-height: 340px; }

.shop-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  background: rgba(255,250,230,0.4);
  border: 1px solid rgba(163,129,45,0.2);
  padding: 7px 8px;
  margin-bottom: 5px;
}
.shop-item-left { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0; }
.shop-icon { font-size: 18px; flex-shrink: 0; }
.shop-name { font-family: 'Shippori Mincho', serif; font-size: 12px; font-weight: 700; color: #3a2614; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shop-stats   { font-family: 'Cinzel', serif; font-size: 9px; color: #5b4023; letter-spacing: 0.05em; }
.shop-desc    { font-family: 'Shippori Mincho', serif; font-size: 10px; color: #5b4023; margin-top: 1px; }
.shop-element { font-size: 10px; margin-top: 1px; }
.shop-item-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.shop-price      { font-family: 'Cinzel', serif; font-size: 10px; color: #6e521a; letter-spacing: 0.05em; white-space: nowrap; }
.shop-price.no-gold { color: rgba(122,29,29,0.6); }
.shop-buy-btn { font-size: 11px; padding: 2px 8px; }
.shop-buy-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Monster Book ===== */
#book-list { display: flex; flex-direction: column; gap: 6px; }
.book-entry {
  display: flex;
  gap: 8px;
  padding: 8px;
  background: rgba(255,250,230,0.4);
  border: 1px solid rgba(163,129,45,0.25);
}
.book-entry.book-unknown { border-color: rgba(58,38,20,0.12); background: rgba(236,225,196,0.3); }
.book-icon { font-size: 22px; width: 28px; text-align: center; flex-shrink: 0; line-height: 1; margin-top: 2px; }
.book-silhouette { font-size: 22px; width: 28px; text-align: center; flex-shrink: 0; color: rgba(58,38,20,0.15); background: rgba(58,38,20,0.07); line-height: 26px; filter: blur(2px); }
.book-info { flex: 1; min-width: 0; }
.book-name { font-family: 'Shippori Mincho', serif; font-size: 12px; font-weight: 700; color: #3a2614; margin-bottom: 2px; }
.unknown-name { color: rgba(58,38,20,0.12) !important; letter-spacing: 3px; }
.book-stars { font-size: 11px; letter-spacing: 1px; color: #a3812d; margin-bottom: 3px; }
.book-stats-row { display: flex; gap: 8px; font-family: 'Cinzel', serif; font-size: 9px; color: #5b4023; margin-bottom: 3px; letter-spacing: 0.05em; }
.book-desc { font-family: 'Shippori Mincho', serif; font-size: 10px; color: #5b4023; line-height: 1.5; margin-bottom: 3px; }
.book-kills { font-family: 'Cinzel', serif; font-size: 9px; color: #5b4023; letter-spacing: 0.05em; }
.book-kills strong { color: #7a1d1d; }

/* ===== Refine Badge ===== */
.refine-badge {
  display: inline-block;
  font-family: 'Cinzel', serif;
  font-size: 9px;
  font-weight: 700;
  color: #5b4023;
  background: rgba(58,38,20,0.07);
  border: 1px solid rgba(163,129,45,0.4);
  padding: 0 3px;
  margin-left: 4px;
  vertical-align: middle;
  line-height: 1.4;
  letter-spacing: 0.05em;
}
.refine-badge.maxed {
  color: #a3812d;
  animation: refine-glow 1.5s ease-in-out infinite alternate;
}
@keyframes refine-glow {
  from { box-shadow: 0 0 3px rgba(163,129,45,0.3); }
  to   { box-shadow: 0 0 8px rgba(163,129,45,0.7); }
}

/* ===== Mobile Layout ===== */
@media (max-width: 767px) {
  body { overflow-y: auto; height: auto; }
  #wrapper {
    display: flex;
    flex-direction: column;
    height: auto;
    min-width: unset;
    max-width: 100%;
    gap: 4px;
    padding: 4px;
  }
  #title-strip { padding: 3px 8px; }
  .title-strip-lat { font-size: 9px; letter-spacing: 0.2em; }
  .title-strip-jp { font-size: 9px; }
  #top-hud { flex-wrap: wrap; gap: 6px; padding: 6px 10px; }
  #player-block { flex-wrap: wrap; width: 100%; }
  .bar-bg { width: 70px; }
  #time-block { gap: 8px; flex-wrap: wrap; }
  #stat-block { gap: 8px; flex-wrap: wrap; }
  .time-item, .stat-item { font-size: 10px; }
  #main-area { gap: 4px; }
  #game-wrap {
    width: 100%;
    aspect-ratio: 750 / 480;
    flex: unset;
    overflow: hidden;
    max-width: 100vw;
  }
  #game-container {
    width: 100%;
    height: 100%;
    overflow: hidden;
  }
  #game-container canvas {
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
  }
  #battle-log { height: 100px; }
  #side-panel { grid-column: unset; grid-row: unset; height: 280px; min-height: unset; }
  .modal-box { min-width: unset; width: 90vw; max-width: 400px; padding: 16px; }
  .guild-choice-card { width: 120px; padding: 10px; }
}

/* ===== Tablet ===== */
@media (min-width: 768px) and (max-width: 900px) {
  #wrapper { min-width: unset; grid-template-columns: 1fr 210px; }
  .bar-bg { width: 70px; }
  #time-block { gap: 8px; }
  #stat-block { gap: 8px; }
  #game-wrap { overflow: hidden; }
  #game-container canvas { max-width: 100%; max-height: 100%; }
}
