:root {
  --bg-dark: #050a05;
  --bg-bezel: #181c18;
  --bg-panel: #121512;
  --green: #33ff66;
  --green-dim: #1d9a3e;
  --amber: #ffb000;
  --cyan: #38e8ff;
  --red: #ff5555;
  --white: #d8ead8;
  --border: #2a4a2e;
  --font-mono: "MS Gothic", "Osaka-Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #000;
  color: var(--green);
  font-family: var(--font-mono);
  overflow: hidden;
  touch-action: manipulation;
}

#app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 440px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg-bezel);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* 上半分：CRTモニタ (約56%) */
#monitor-section {
  flex: 1 1 56%;
  min-height: 0;
  padding: 6px 6px 4px;
  display: flex;
  flex-direction: column;
}

#crt-bezel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-dark);
  border: 2px solid #3c463c;
  border-radius: 6px;
  box-shadow: inset 0 0 18px rgba(0, 255, 100, 0.08);
  overflow: hidden;
  position: relative;
}

#crt-bezel::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.16) 3px
  );
}

#crt-statusbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  background: #0e2412;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--cyan);
  flex-shrink: 0;
  z-index: 1;
}

#status-center {
  color: var(--amber);
  font-weight: bold;
}

#crt-screen {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.45;
  -webkit-overflow-scrolling: touch;
  z-index: 1;
}

#screen-content {
  white-space: pre-wrap;
  word-break: break-word;
}

.line-title {
  color: var(--cyan);
  font-weight: bold;
}

.line-amber {
  color: var(--amber);
}

.line-red {
  color: var(--red);
  font-weight: bold;
}

.line-dim {
  color: var(--green-dim);
  font-size: 12px;
}

.line-user {
  color: var(--white);
}

.msg-block {
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px dashed #16331b;
}

.msg-sender {
  color: var(--amber);
  font-weight: bold;
}

.msg-sender.self {
  color: var(--cyan);
}

.menu-item {
  padding: 2px 0;
  cursor: pointer;
}

.menu-item.selected {
  background: var(--green);
  color: #000;
  font-weight: bold;
}

/* テキスト入力バー */
#crt-input-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  background: #09130a;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 2;
}

#input-prompt {
  color: var(--amber);
  font-weight: bold;
  font-size: 14px;
}

#text-input {
  flex: 1;
  min-width: 0;
  background: #040804;
  color: var(--green);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 5px 7px;
  font-family: var(--font-mono);
  font-size: 14px;
  outline: none;
}

#text-input:focus {
  border-color: var(--green);
}

#send-btn {
  background: #14361b;
  color: var(--green);
  border: 1px solid var(--green-dim);
  border-radius: 3px;
  padding: 5px 10px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  flex-shrink: 0;
}

#send-btn:active {
  background: var(--green);
  color: #000;
}

/* 下半分：常時表示テンキー＋右側上下スクロール (約44%) */
#keypad-section {
  flex: 0 0 42%;
  min-height: 220px;
  max-height: 300px;
  padding: 4px 8px 8px;
  background: var(--bg-panel);
  border-top: 2px solid #303630;
  display: flex;
}

#keypad-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 6px;
}

.key-btn {
  background: linear-gradient(180deg, #2b322b 0%, #1c211c 100%);
  color: var(--white);
  border: 1px solid #485448;
  border-bottom-width: 3px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.key-btn:active {
  transform: translateY(1px);
  border-bottom-width: 1px;
  background: #33ff66;
  color: #000;
}

.key-scroll {
  background: linear-gradient(180deg, #1b362a 0%, #10241b 100%);
  color: var(--cyan);
  border-color: #2e6b52;
  font-size: 22px;
}

.key-func {
  background: linear-gradient(180deg, #332c1d 0%, #221d12 100%);
  color: var(--amber);
  border-color: #665528;
  font-size: 15px;
}

.key-enter {
  background: linear-gradient(180deg, #194224 0%, #0f2b16 100%);
  color: var(--green);
  border-color: #2f7d42;
  font-size: 15px;
}

.key-menu {
  background: linear-gradient(180deg, #252b38 0%, #171b24 100%);
  color: var(--cyan);
  border-color: #3e4e6e;
  font-size: 14px;
}
