/* 手机版：一台 3100 年代的直板机。 */
.ph {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at 50% 30%, #4a4038, #1c1814);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  /* 彩屏（3100） */
  --lcd-bg: #e9eef6;
  --lcd-fg: #13213f;
  --lcd-hd: #2350b0;
  --lcd-hd-fg: #fff;
  --lcd-on: #2350b0;
  --lcd-on-fg: #fff;
  --lcd-game: #bcd99a;
}

/* 黑白（3310 怀旧） */
.ph.mono {
  --lcd-bg: #b7c99a;
  --lcd-fg: #1f2a14;
  --lcd-hd: #1f2a14;
  --lcd-hd-fg: #b7c99a;
  --lcd-on: #1f2a14;
  --lcd-on-fg: #b7c99a;
  --lcd-game: #b7c99a;
}

.ph.mono .lcd .px-icon {
  filter: grayscale(1) contrast(4) brightness(0.9);
  mix-blend-mode: multiply;
}

.ph button {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.ph button:active {
  transform: translateY(1px);
  filter: brightness(1.25);
}

.ph button:focus-visible {
  outline: 2px solid #ff0;
}

/* ── 机身 ── */
.ph-body {
  width: min(100vw, 400px);
  box-sizing: border-box;
  padding: 14px 20px 22px;
  border-radius: 46px 46px 64px 64px;
  background: linear-gradient(160deg, #6c7684, #3a414b 45%, #2a3038);
  box-shadow: inset 0 2px 0 #9aa4b2, inset 0 -3px 6px #0006, 0 10px 40px #000a;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.ph-speaker {
  width: 64px;
  height: 6px;
  border-radius: 3px;
  background: repeating-linear-gradient(90deg, #111 0 4px, #4a525c 4px 7px);
}

.ph-bezel {
  padding: 10px 12px 14px;
  border-radius: 14px 14px 30px 30px;
  background: #15181d;
  box-shadow: inset 0 0 0 2px #8a95a3, inset 0 0 0 4px #15181d, inset 0 0 0 5px #333;
}

.ph-brand {
  color: #c9d1dc;
  font: bold 13px/1 Arial, sans-serif;
  letter-spacing: 5px;
  text-shadow: 0 1px 0 #000;
}

/* ── 屏幕：128×128 逻辑像素，整体放大 --s 倍 ── */
.lcd-wrap {
  --s: 2;
  width: calc(128px * var(--s));
  height: calc(128px * var(--s));
  overflow: hidden;
  border-radius: 2px;
}

.lcd {
  position: relative;
  width: 128px;
  height: 128px;
  transform: scale(var(--s));
  transform-origin: 0 0;
  display: grid;
  grid-template-rows: 12px 103px 13px;
  overflow: hidden;
  background: var(--lcd-bg);
  color: var(--lcd-fg);
  font: 12px/13px var(--px);
  -webkit-font-smoothing: none;
}

.lcd p {
  margin: 0;
}

.lcd .px-icon {
  image-rendering: pixelated;
}

.lcd-status {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 1px 3px 2px;
}

.lcd-status i {
  display: inline-block;
  width: 2px;
  margin-right: 1px;
  background: var(--lcd-fg);
}

.sig i:nth-child(1) { height: 3px; }
.sig i:nth-child(2) { height: 5px; }
.sig i:nth-child(3) { height: 7px; }
.sig i:nth-child(4) { height: 9px; }

.bat {
  display: flex;
  gap: 1px;
  padding: 1px;
  border: 1px solid var(--lcd-fg);
}

.bat i {
  width: 3px !important;
  height: 5px;
  margin: 0 !important;
}

.lcd-content {
  position: relative;
  overflow: hidden;
}

.lcd-soft {
  display: flex;
  justify-content: space-between;
  padding: 0 3px;
}

.lcd-soft span {
  cursor: pointer;
  min-width: 24px;
}

.lcd-soft span:last-child {
  text-align: right;
}

/* 标题栏 */
.lcd .hd {
  display: flex;
  justify-content: space-between;
  height: 13px;
  padding: 0 3px;
  background: var(--lcd-hd);
  color: var(--lcd-hd-fg);
  white-space: nowrap;
  overflow: hidden;
}

/* 列表 */
.lcd .ls {
  list-style: none;
  margin: 1px 0 0;
  padding: 0 6px 0 0;
}

.lcd .ls li {
  height: 13px;
  padding: 0 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

.lcd .ls li.on {
  background: var(--lcd-on);
  color: var(--lcd-on-fg);
}

.lcd .sb {
  position: absolute;
  right: 1px;
  top: 15px;
  bottom: 2px;
  width: 3px;
  border-left: 1px dotted var(--lcd-fg);
}

.lcd .sb i {
  position: absolute;
  left: 0;
  width: 3px;
  height: 6px;
  margin-top: -3px;
  background: var(--lcd-fg);
}

/* 文字页 */
.lcd .tx {
  height: 88px;
  margin-top: 1px;
  padding: 0 3px;
  overflow: hidden;
  word-break: break-all;
}

.lcd .tx div {
  transition: transform 0.1s;
}

/* 待机 */
.lcd-content.standby {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.standby .op {
  margin-top: 1px;
}

.standby .wall {
  height: 34px;
  margin-top: 4px;
}

.standby .time {
  font-size: 24px;
  line-height: 26px;
  margin-top: 4px;
}

/* 主菜单 3×3 */
.menu .grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 29px);
  padding: 2px 4px 0;
}

.menu .grid div {
  display: flex;
  align-items: center;
  justify-content: center;
}

.menu .grid div.on {
  background: var(--lcd-on);
  border-radius: 3px;
}

/* 拨号 */
.lcd-content.dial {
  display: flex;
  align-items: flex-end;
}

.dial .digits {
  width: 100%;
  padding: 0 3px 2px;
  font-size: 24px;
  line-height: 26px;
  text-align: right;
  word-break: break-all;
}

.lcd-content.center {
  text-align: center;
  padding-top: 8px;
}

.call-anim {
  animation: shake 0.3s steps(2) infinite;
}

@keyframes shake {
  50% {
    transform: translateX(2px);
  }
}

.lcd .big1 {
  margin: 2px 0;
}

/* 开机 */
.lcd-content.boot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.boot-logo {
  font-size: 24px;
  line-height: 26px;
  letter-spacing: 2px;
  animation: rise 1s steps(6);
}

@keyframes rise {
  from {
    transform: translateY(40px);
  }
}

/* 游戏 */
.game canvas {
  display: block;
  margin: 1px auto 0;
  width: 120px;
  height: 88px;
  image-rendering: pixelated;
  outline: 1px solid var(--lcd-fg);
}

/* 彩蛋弹窗 */
.lcd-popup {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 22px;
  padding: 4px 3px 2px;
  background: var(--lcd-bg);
  border: 1px solid var(--lcd-fg);
  box-shadow: 2px 2px 0 var(--lcd-fg);
  text-align: center;
}

.pop-soft {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  border-top: 1px dotted var(--lcd-fg);
}

/* ── 按键区 ── */
.ph-cluster {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 100px 1fr;
  grid-template-rows: 44px 44px;
  gap: 4px 12px;
  align-items: center;
}

.ph .soft,
.ph .call,
.ph .end {
  height: 30px;
  border-radius: 15px;
  background: linear-gradient(#d9dee5, #9aa3ae);
  box-shadow: 0 2px 0 #1a1d22;
  position: relative;
}

.ph .soft::after {
  content: '';
  position: absolute;
  left: 30%;
  right: 30%;
  top: 13px;
  height: 3px;
  border-radius: 2px;
  background: #3b4450;
}

.ph .soft.l { grid-area: 1 / 1; }
.ph .soft.r { grid-area: 1 / 3; }
.ph .call { grid-area: 2 / 1; background: linear-gradient(#5fd46a, #22903a); }
.ph .end { grid-area: 2 / 3; background: linear-gradient(#f06a5f, #b02a22); }

.ph .call::after,
.ph .end::after {
  content: '';
  position: absolute;
  left: calc(50% - 9px);
  top: 11px;
  width: 18px;
  height: 7px;
  border-radius: 7px 7px 2px 2px;
  background: #fff;
}

.ph .end::after {
  transform: rotate(180deg);
}

.dpad {
  grid-area: 1 / 2 / 3 / 3;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 30%, #c2cad4, #7b8592);
  box-shadow: 0 3px 0 #1a1d22, inset 0 0 0 2px #5c6672;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
}

.dpad [data-k='up'] { grid-area: 1 / 2; }
.dpad [data-k='left'] { grid-area: 2 / 1; }
.dpad [data-k='ok'] { grid-area: 2 / 2; border-radius: 50%; background: radial-gradient(#e6eaef, #a5aeb9); box-shadow: 0 1px 0 #3b4450; }
.dpad [data-k='right'] { grid-area: 2 / 3; }
.dpad [data-k='down'] { grid-area: 3 / 2; }

.dpad [data-k]:not([data-k='ok'])::after {
  content: '';
  display: block;
  margin: 13px auto;
  width: 0;
  height: 0;
  border: 5px solid transparent;
}

.dpad [data-k='up']::after { border-bottom-color: #3b4450; border-top: 0; }
.dpad [data-k='down']::after { border-top-color: #3b4450; border-bottom: 0; }
.dpad [data-k='left']::after { border-right-color: #3b4450; border-left: 0; }
.dpad [data-k='right']::after { border-left-color: #3b4450; border-right: 0; }

/* 夜光数字键 */
.ph-pad {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px 12px;
}

.ph-pad button {
  height: 38px;
  border-radius: 40% 40% 50% 50% / 50%;
  background: linear-gradient(#3c434d, #262b32);
  box-shadow: 0 2px 0 #111, inset 0 1px 0 #5a636e;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  padding-top: 8px;
}

.ph-pad b {
  font: bold 18px/1 Arial, sans-serif;
  color: #9dff9a;
  text-shadow: 0 0 6px #4f4;
}

.ph-pad small {
  font: 10px/1 Arial, sans-serif;
  color: #9fb6a0;
}
