/* Layout: HUD, World Tags, Radio, Dialogue, Touch Pad & PC Toolbar */

/* 上辺HUD */
#hud {
  transition: opacity 0.2s;
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  z-index: 3;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) calc(16px + env(safe-area-inset-right, 0px)) 0 calc(16px + env(safe-area-inset-left, 0px));
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: flex-start;
  pointer-events: none;
}

.obj {
  display: grid;
  gap: 2px;
  padding: 7px 12px 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 2px solid var(--line-brass);
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
  max-width: min(400px, 62vw);
  min-width: 0;
}

.obj .k {
  font: 13px var(--f-px);
  letter-spacing: 0.16em;
  color: var(--gold);
}

.obj .s {
  text-align: justify;   /* 和文の本文は両端そろえ（最後の行は左） */
}

.obj .v,
.obj .s {
  word-break: normal;   /* ふつうの和文の組み方（2026-12-03 本人。文節改行だと、長い文節が入りきらないとき行頭に約物が出た） */
  line-break: strict;   /* 行頭に 。、」ゃっ などを出さない */
  overflow-wrap: break-word;
}

.obj .v {
  font-size: clamp(16px, 1.35vw, 19px);
  line-height: 1.4;
}

.obj .s {
  font: 13px/1.45 var(--f-body);
  color: var(--dim);
}

#hud.dim {
  opacity: 0.3;
}

#eyes {
  display: flex;
  gap: 5px;
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.eye {
  display: grid;
  gap: 3px;
  padding: 4px 4px 5px;
  min-width: 58px;
  background: rgba(11, 13, 27, 0.94);
  border: 1.5px solid var(--line);
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
}

.eye .scr {
  position: relative;
  width: var(--eye);
  height: var(--eye);
  margin: 0 auto;
  border: 1px solid rgba(234, 184, 77, 0.25);
}

.eye[data-s="0"] .scr,
.eye:not([data-s]) .scr {
  border-color: rgba(116, 220, 196, 0.45);
}

.eye canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  background: #000;
}

.eye .scr::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, 0.22) 2px 3px);
  pointer-events: none;
}

.eye .zz {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 14px/1 var(--f-jp);
  color: var(--moon);
  background: rgba(11, 13, 27, 0.78);
}

.eye .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2px;
  font: 13px/1.1 var(--f-jp);
  color: var(--text);
}

.eye .px {
  color: var(--alert);
  font-size: 10px;
  line-height: 1;
  min-height: 6px;
}

.eye .px i {
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-left: 1px;
  background: var(--safe);
}

.eye[data-hot="1"] .px i {
  background: var(--alert);
}

.eye .bar {
  height: 3px;
  background: var(--line);
}

.eye .bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--gold);
  font-variant-numeric: tabular-nums;
}

.eye[data-s="1"] {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(234, 184, 77, 0.35);
}

.eye[data-s="2"] {
  border-color: var(--alert);
  box-shadow: inset 0 0 0 1px rgba(255, 79, 66, 0.45);
}

.eye[data-s="2"] .bar i {
  background: var(--alert);
}

.eye.big .row span:first-child {
  color: var(--gold);
}

.eye.cam {
  min-width: 48px;
}

.eye.cam .scr {
  width: calc(var(--eye) * 0.78);
  height: calc(var(--eye) * 0.78);
}

.eye.cam .row {
  font-size: 12px;
}

.eye.cam .zz {
  color: var(--dim);
}

.eye.cam[data-s="2"] .zz {
  color: var(--alert);
}

/* 右上チップ: どの画面幅でも下部ボタンと重ならないよう上辺右に配置 */
#topR {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right, 0px));
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  z-index: 4;
  display: flex;
  gap: 6px;
}

#topR[data-night="1"] {
  top: calc(env(safe-area-inset-top, 0px) + var(--eye) + 46px);
}

.chip {
  font-size: 15px;
  padding: 7px 11px 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-btn);
  box-shadow: inset 0 1px 0 rgba(234, 184, 77, 0.2);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: border-color 140ms ease, transform 80ms ease;
}

.chip:active {
  transform: translateY(2px);
}

@media (hover: hover) {
  .chip:hover {
    border-color: var(--gold);
  }
}

.chip .ic {
  margin-right: 3px;
}

.chip b {
  font: 600 14px var(--f-mono);
  color: var(--gold);
  margin-left: 2px;
  font-variant-numeric: tabular-nums;
}

/* タッチ / 狭幅レイアウト: #topR は常に右上、#eyes は2段目へ逃がし、#obj と #btns の衝突を根絶 */
@media (pointer: coarse), (max-width: 640px) {
  #hud {
    padding: calc(env(safe-area-inset-top, 0px) + 10px) calc(10px + env(safe-area-inset-right, 0px)) 0 calc(10px + env(safe-area-inset-left, 0px));
  }
  .obj {
    max-width: min(330px, calc(100vw - 176px));
  }
  #eyes {
    flex-basis: 100%;
    margin-left: 0;
    justify-content: flex-end;
  }
  #topR,
  #topR[data-night="1"] {
    top: calc(env(safe-area-inset-top, 0px) + 10px);
    right: calc(10px + env(safe-area-inset-right, 0px));
    left: auto;
    bottom: auto;
    flex-direction: row;
    align-items: center;
  }
  .chip {
    min-height: 44px;
    min-width: 44px;
    font-size: 12px;
    padding: 8px 10px;
  }
  .chip .lbl {
    display: none;
  }
  .chip .sm-hide {
    display: none;
  }
}

html[data-input="touch"] #hud {
  padding: calc(env(safe-area-inset-top, 0px) + 10px) calc(10px + env(safe-area-inset-right, 0px)) 0 calc(10px + env(safe-area-inset-left, 0px));
}
html[data-input="touch"] .obj {
  max-width: min(330px, calc(100vw - 176px));
}
html[data-input="touch"] #eyes {
  --eye: min(56px, calc((100vw - 20px - (var(--n, 4) - 1) * 4px) / var(--n, 4) - 11px));   /* 何人いても1段に収める */
  flex-basis: 100%;
  flex-wrap: nowrap;
  gap: 4px;
  margin-left: 0;
  justify-content: flex-end;
}
html[data-input="touch"] .eye {
  min-width: 0;
}
html[data-input="touch"] .eye .row,
html[data-input="touch"] .eye.cam .row {
  font-size: 11px;
  white-space: nowrap;
}
html[data-input="touch"] #topR,
html[data-input="touch"] #topR[data-night="1"] {
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: calc(10px + env(safe-area-inset-right, 0px));
  left: auto;
  bottom: auto;
  flex-direction: row;
  align-items: center;
}
html[data-input="touch"] .chip {
  min-height: 44px;
  min-width: 44px;
  font-size: 12px;
  padding: 8px 10px;
}
html[data-input="touch"] .chip .lbl,
html[data-input="touch"] .chip .sm-hide {
  display: none;
}

@media (max-width: 380px) {
  .chip .sm-hide {
    display: none;
  }
  .obj,
  html[data-input="touch"] .obj {
    max-width: min(330px, calc(100vw - 168px));
  }
}

/* ワールド上のラベル */
#tags {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.tag {
  position: absolute;
  left: 0;
  top: 0;
  font: 13px var(--f-px);
  line-height: 1;
  padding: 3px 5px 2px;
  background: var(--panel);
  border: 1px solid var(--line);
  white-space: nowrap;
  will-change: transform;
}

.tag.act {
  z-index: 3;
  font: 17px var(--f-jp);
  color: var(--paper);
  border-color: var(--gold);
  padding: 6px 11px 5px;
  box-shadow: 0 3px 0 rgba(6, 7, 16, 0.55);
}

.tag.act kbd {
  font: 600 13px var(--f-mono);
  color: var(--gold);
  margin-right: 5px;
}

.tag.name {
  font: 15px var(--f-jp);
  color: var(--paper);
  background: rgba(11, 13, 27, 0.8);
  border: 0;
  padding: 3px 8px 2px;
}

.tag.emo {
  font: 700 20px var(--f-px);
  text-align: center;
  color: var(--gold);
}

.tag.emo[data-s="2"] {
  color: var(--alert);
}

.tag.emo i {
  display: block;
  width: 34px;
  height: 4px;
  margin-top: 4px;
  background: var(--line);
}

.tag.emo i s {
  display: block;
  height: 100%;
  width: 0;
  background: currentColor;
  text-decoration: none;
}

.tag.me {
  color: var(--gold);
  font: 15px var(--f-jp);
  padding: 4px 8px 3px;
}

.tag.sneak {
  font: 13px var(--f-jp);
  color: var(--moon);
  border-color: var(--moon-deep);
  padding: 2px 6px 1px;
}

.tag.me[data-s="2"] {
  color: var(--alert);
  border-color: var(--alert);
}

.tag.zz {
  color: var(--moon);
  background: transparent;
  border: 0;
  font: 16px var(--f-jp);
  text-shadow: 0 2px 0 #05060f;
}

.tag.chan {
  font: 15px var(--f-jp);
  color: var(--gold);
}

.tag.gsay {
  z-index: 2;
  font: 16px/1.2 var(--f-jp);
  color: var(--paper-ink);
  background: var(--paper);
  border: 0;
  border-radius: 9px;
  padding: 7px 12px 6px;
  box-shadow: 0 2px 0 var(--paper-line);
  margin-top: -6px;
}

.tag.gsay::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  margin-left: -5px;
  border: 5px solid transparent;
  border-bottom: 0;
  border-top-color: var(--paper);
}

.tag.gsay[data-s="2"] {
  color: #fff;
  background: var(--alert);
  box-shadow: 0 2px 0 #6a1a14;
}

.tag.gsay[data-s="2"]::after {
  border-top-color: var(--alert);
}

.tag.chan i {
  width: 84px;
}

#arrow {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 2;
  pointer-events: none;
  width: 18px;
  height: 18px;
  background: var(--gold);
  clip-path: polygon(50% 0, 100% 100%, 50% 78%, 0 100%);
}

#arrowD {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 2;
  pointer-events: none;
  font: 600 14px var(--f-mono);
  color: var(--gold);
  text-shadow: 0 1px 0 #000, 0 0 4px #000;
  font-variant-numeric: tabular-nums;
}

#toast {
  position: fixed;
  left: 50%;
  top: 30%;
  transform: translate(-50%, -50%);
  z-index: 6;
  padding: 10px 16px;
  background: var(--panel);
  border: 1px solid var(--gold);
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
  color: var(--gold);
  font-size: 17px;
  line-height: 1.5;
  pointer-events: none;
  width: max-content;
  max-width: min(560px, calc(100vw - 32px));
  text-align: center;
  text-wrap: balance;
  word-break: keep-all;   /* 中央そろえの短い文は文節で折り返す（js/ui/phrase.js）。ふつうの組み方だと「もどっ|て」と語の途中で割れた（2026-12-03） */
  line-break: strict;
  overflow-wrap: anywhere;
}

#nightCue {
  position: fixed;
  left: 50%;
  bottom: calc(20px + var(--tb) + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 2;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  background: rgba(14, 17, 34, 0.9);
  border: 1px solid var(--line-brass);
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  color: var(--paper);
  font: 15px/1.4 var(--f-body);
  max-width: min(520px, calc(100vw - 260px));
  white-space: nowrap;
  transition: opacity 220ms ease-out;
}

#nightCue .ic {
  color: var(--safe);
}

@media (pointer: coarse), (max-width: 640px) {
  #nightCue {
    top: calc(var(--hud-b, 140px) + 8px);
    bottom: auto;
    max-width: calc(100vw - 24px);
    white-space: normal;
  }
}

html[data-input="touch"] #nightCue {
  top: calc(var(--hud-b, 140px) + 8px);
  bottom: auto;
  max-width: calc(100vw - 24px);
  white-space: normal;
}

/* 会話 */
#dlg {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(14px + var(--tb) + env(safe-area-inset-bottom, 0px));
  z-index: 7;
  width: min(820px, calc(100vw - 24px));
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0 16px;
  padding: 14px 16px 16px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.45);
  pointer-events: auto;
}

#dlg .pf {
  grid-row: 1 / span 3;
  width: 112px;
  height: 112px;
  background: var(--who, #334);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: grid;
  place-items: end center;
  overflow: hidden;
}

#portrait {
  width: 112px;
  height: 112px;
  image-rendering: pixelated;
  display: block;
}

#dlgWho {
  font-size: 16px;
  color: var(--who-ink, var(--gold));
  letter-spacing: 0.04em;
  padding-bottom: 4px;
}

#dlgTxt {
  font-size: 21px;
  text-align: justify;   /* 和文の本文は両端そろえ（最後の行は左） */
  line-height: 1.6;
  min-height: 3.2em;
  white-space: pre-wrap;
  word-break: normal;   /* ふつうの和文の組み方（2026-12-03 本人。文節改行だと、長い文節が入りきらないとき行頭に約物が出た） */
  line-break: strict;   /* 行頭に 。、」ゃっ などを出さない */
  overflow-wrap: break-word;
  min-width: 0;
  padding-right: 26px;
}

#dlgCh {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 8px;
}

#dlgCh button {
  text-wrap: balance;   /* 2行になるときは、文節で半分ずつに */
  word-break: keep-all;   /* 中央そろえの短い文は文節で折り返す（js/ui/phrase.js）。ふつうの組み方だと「もどっ|て」と語の途中で割れた（2026-12-03） */
  line-break: strict;
  overflow-wrap: anywhere;
  border-radius: var(--r-btn);
  font-size: 18px;
  padding: 8px 14px 7px;
  min-height: 44px;
  min-width: 44px;
  background: var(--paper);
  color: var(--paper-ink);
  border: 0;
  box-shadow: 0 3px 0 var(--paper-line);
  transition: transform 80ms ease, box-shadow 80ms ease;
}

#dlgCh button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--paper-line);
}

#dlgNext {
  position: absolute;
  right: 0;
  bottom: 0;
  min-width: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
  pointer-events: none;
}

#dlgNext::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid var(--gold);
}

#dlg .pf2 {
  display: none;
  grid-row: 1 / span 3;
  grid-column: 3;
  width: 112px;
  height: 112px;
  background: #1a2a24;
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

#portrait2 {
  width: 112px;
  height: 112px;
  image-rendering: pixelated;
  display: block;
}

/* ナルサ通信 */
#dlg.codec {
  grid-template-columns: auto minmax(0, 1fr) auto;
  background: var(--nalsa-bg);
  border-color: var(--nalsa-deep);
}

#dlg.codec .pf {
  background: #3a2414;
  border-radius: 32px 32px 6px 6px;
}

#dlg.codec .pf2 {
  display: block;
  background: #2a2238;
  border-radius: 32px 32px 6px 6px;
}

#dlg.codec .dim {
  opacity: 0.45;
  filter: saturate(0.4);
}

#dlg .freq {
  display: none;
  position: absolute;
  left: 50%;
  top: -14px;
  transform: translateX(-50%);
  font-size: 14px;
  color: var(--nalsa);
  background: var(--nalsa-bg);
  border: 1px solid var(--nalsa-deep);
  padding: 2px 10px 1px;
  white-space: nowrap;
}

#dlg.codec .freq {
  display: block;
}

#callin {
  position: fixed;
  left: 50%;
  top: 32%;
  transform: translate(-50%, -50%);
  z-index: 9;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 10px 22px 10px;
  background: var(--nalsa-bg);
  border: 2px solid var(--nalsa-deep);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

#callin .ci-k {
  font-size: 26px;
  letter-spacing: 0.2em;
  color: var(--nalsa);
}

#callin .ci-t {
  font-size: 16px;
  color: var(--paper);
}

#radio {
  position: fixed;
  left: calc(16px + env(safe-area-inset-left, 0px));
  top: 0;
  z-index: 6;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  width: min(460px, calc(100vw - 32px));
  padding: 7px 12px 7px 7px;
  background: rgba(30, 20, 12, 0.94);
  border: 1px solid var(--nalsa-deep);
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
  pointer-events: none;
}

#radio canvas {
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
  background: #3a2414;
  border-radius: 26px 26px 4px 4px;
  display: block;
}

#radio .rw {
  display: block;
  font-size: 13px;
  color: var(--nalsa);
  margin-bottom: 2px;
}

#radio .rt {
  font-size: 16px;
  text-align: justify;   /* 和文の本文は両端そろえ（最後の行は左） */
  line-height: 1.5;
  color: var(--paper);
  min-width: 0;
  word-break: normal;   /* ふつうの和文の組み方（2026-12-03 本人。文節改行だと、長い文節が入りきらないとき行頭に約物が出た） */
  line-break: strict;   /* 行頭に 。、」ゃっ などを出さない */
  overflow-wrap: break-word;
}

#radio[data-pri="1"] {
  border-color: var(--gold);
  background: rgba(28, 20, 6, 0.94);
}

#radio[data-who="t"] {
  border-color: #7a5aa8;
  background: rgba(20, 12, 30, 0.94);
}

#radio[data-who="t"] .rw {
  color: #c8a8ff;
}

#radio[data-who="t"] canvas {
  background: #2a1a3a;
}

#radio[data-pri="1"] .rw {
  color: var(--gold);
}

@media (max-width: 480px) {
  #dlg .pf, #portrait, #dlg .pf2, #portrait2 {
    width: 64px;
    height: 64px;
  }
  #dlgWho {
    font-size: 14px;
  }
  #dlgTxt {
    font-size: 18px;
    line-height: 1.5;
  }
  #dlgCh button {
    font-size: 16px;
  }
  #dlg.codec .pf, #dlg.codec #portrait, #dlg.codec .pf2, #dlg.codec #portrait2 {
    width: 52px;
    height: 52px;
  }
  #radio .rt {
    font-size: 15px;
  }
  #dlg.codec {
    gap: 0 8px;
  }
}

/* スマホ操作 */
#pad {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

#joy {
  position: fixed;
  left: 0;
  top: 0;
  width: 108px;
  height: 108px;
  margin: -54px 0 0 -54px;
  border: 2px solid rgba(180, 193, 255, 0.3);
  border-radius: 50%;
}

#knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42px;
  height: 42px;
  margin: -21px 0 0 -21px;
  border-radius: 50%;
  background: rgba(180, 193, 255, 0.32);
}

#btns {
  position: fixed;
  right: calc(14px + env(safe-area-inset-right, 0px));
  bottom: calc(18px + var(--tb) + env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-columns: auto auto auto;
  gap: 10px;
  align-items: end;
  justify-items: center;
  pointer-events: auto;
}

.rb {
  width: 74px;
  height: 74px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  padding: 0;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 13px;
  color: var(--text);
  background: rgba(14, 17, 34, 0.84);
  border: 2px solid var(--moon-deep);
  line-height: 1.15;
  transition: transform 80ms ease, border-color 140ms ease;
}

.rb .ic {
  width: 17px;
  height: 17px;
}

.rb.main {
  width: 86px;
  height: 86px;
  font-size: 15px;
  border-color: var(--gold);
  color: var(--paper);
}

.rb.main .ic {
  width: 20px;
  height: 20px;
}

.rb[aria-pressed="true"] {
  background: var(--moon);
  color: var(--night);
  border-color: var(--moon);
}

.rb:not(:disabled):active {
  transform: scale(0.94);
}

.rb small {
  display: block;
  font: 600 11px/1 var(--f-mono);
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.rb:disabled {
  opacity: 0.42;
}

#bCall {
  grid-column: 1;
  grid-row: 2;
  width: 64px;
  height: 64px;
  font-size: 12px;
  border-color: var(--nalsa-deep);
  color: var(--nalsa);
}

#bCall .ic {
  width: 16px;
  height: 16px;
}

.rb.tool {
  width: 66px;
  height: 66px;
  font-size: 12px;
  border-color: var(--gold);
}

.rb.tool .ic {
  width: 15px;
  height: 15px;
}

#bTool2 {
  grid-column: 2;
  grid-row: 1;
}

#bTool {
  grid-column: 3;
  grid-row: 1;
}

#bCrouch {
  grid-column: 2;
  grid-row: 2;
}

#bAct {
  grid-column: 3;
  grid-row: 2;
}

#hint {
  position: fixed;
  left: calc(16px + env(safe-area-inset-left, 0px));
  bottom: calc(22px + var(--tb) + env(safe-area-inset-bottom, 0px));
  max-width: calc(100vw - 268px);
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  text-shadow: 0 1px 0 #000, 0 0 4px #000;
}

@media (max-width: 380px) {
  #btns {
    right: calc(10px + env(safe-area-inset-right, 0px));
    gap: 6px;
  }
  .rb {
    width: 64px;
    height: 64px;
    font-size: 13px;
  }
  .rb.main {
    width: 74px;
    height: 74px;
    font-size: 14px;
  }
  .rb.tool {
    width: 58px;
    height: 58px;
    font-size: 12px;
  }
  #bCall {
    width: 56px;
    height: 56px;
    font-size: 12px;
  }
  #hint {
    left: calc(10px + env(safe-area-inset-left, 0px));
    max-width: calc(100vw - 232px);
    font-size: 11px;
  }
}

/* パソコン用: 持っている道具とキー (クリックも可) */
#toolbar {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: calc(16px + var(--tb) + env(safe-area-inset-bottom, 0px));
  z-index: 3;
  display: flex;
  gap: 6px;
  pointer-events: none;
}

.tb {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  min-width: 44px;
  padding: 7px 11px 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-btn);
  box-shadow: inset 0 1px 0 rgba(234, 184, 77, 0.2);
  font-size: 17px;
  pointer-events: auto;
  cursor: pointer;
  transition: border-color 140ms ease, transform 80ms ease;
}

.tb:not([data-empty="1"]):active {
  transform: translateY(2px);
}

@media (hover: hover) {
  .tb:hover:not([data-empty="1"]) {
    border-color: var(--gold);
  }
}

.tb kbd {
  border-radius: 3px;
  font: 600 14px var(--f-mono);
  color: var(--night);
  background: var(--gold);
  padding: 2px 5px 1px;
}

.tb i {
  font: 600 15px var(--f-mono);
  font-style: normal;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.tb[data-empty="1"] {
  opacity: 0.45;
  cursor: default;
}

/* パソコン用: 左下に小さくキーの案内 */
#keys {
  position: fixed;
  left: calc(14px + env(safe-area-inset-left, 0px));
  bottom: calc(14px + var(--tb) + env(safe-area-inset-bottom, 0px));
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  max-width: calc(100vw - 380px);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  opacity: 0.82;
  text-shadow: 0 1px 0 #000, 0 0 4px #000;
  pointer-events: none;
}

#keys[hidden] {
  display: none !important;
}

#keys span {
  white-space: nowrap;
}

#keys kbd {
  margin-right: 4px;
  padding: 0 4px;
  border: 1px solid rgba(234, 184, 77, 0.55);
  border-radius: 3px;
  font: 600 11px var(--f-mono);
  color: var(--gold);
  background: rgba(10, 11, 20, 0.55);
  text-shadow: none;
}

html[data-input="touch"] #keys {
  display: none !important;
}

@media (max-width: 760px), (max-height: 420px) {
  #keys {
    display: none !important;
  }
}

/* 動的入力モード切替 (PC / Touch ハイブリッド対応) */
html[data-input="pc"] #pad {
  display: none !important;
}

html[data-input="touch"] #toolbar {
  display: none !important;
}

/* 開きかっこと次の字は折り返さない（js/ui/phrase.js） */
.nb {
  white-space: nowrap;
}

/* 1字ずつ出す文の、まだ出ていない字（場所だけとる） */
.ph-rest {
  visibility: hidden;
}
