@font-face {
  font-family: "Roboto Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/roboto-mono-calc.woff2") format("woff2");
  unicode-range: U+20, U+28-3A, U+3D, U+44-45, U+49, U+4F, U+52, U+56, U+D7,
    U+F7;
}

@font-face {
  font-family: "Noto Sans JP";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/noto-sans-jp-ui.woff2") format("woff2");
  unicode-range: U+3A, U+41, U+43, U+45, U+48, U+4D-4E, U+55, U+69, U+6E-6F,
    U+72-74, U+79, U+25B2-25B3, U+25B6, U+25BC, U+25C0, U+62BC, U+9577;
}

@font-face {
  font-family: "Noto Sans JP";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/noto-sans-jp-ui-bold.woff2") format("woff2");
  unicode-range: U+3A, U+41, U+43, U+45, U+48, U+4D-4E, U+55, U+69, U+6E-6F,
    U+72-74, U+79, U+25B2-25B3, U+25B6, U+25BC, U+25C0, U+62BC, U+9577;
}

:root {
  color-scheme: dark;
  --bg: #120c18;
  --surface: #1c1526;
  --display: #16101f;
  --btn: #2a2138;
  --btn-op: #322844;
  --btn-active: #43355a;
  --accent: #8b5cf6;
  --accent-deep: #7c3aed;
  --text: #f3eefe;
  --muted: #a394b8;
  --line: #3b2f4f;
  --ad: #23182f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: 100lvh;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Noto Sans JP", "Segoe UI", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 100%;
  min-height: 100lvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0
    env(safe-area-inset-left);
}

.install-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  background: #241833;
  border-bottom: 1px solid var(--line);
}

.install-bar[hidden] {
  display: none;
}

.install-bar p {
  margin: 0;
  flex: 1;
  font-size: 13px;
}

.install-bar button {
  border: 0;
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
  color: var(--text);
  background: var(--accent-deep);
}

.install-bar .ghost {
  background: transparent;
  color: var(--muted);
}

.osusume-slot {
  flex: 0 0 auto;
  padding: 8px 10px 0;
}

.osusume-slot[hidden] {
  display: none;
}

.osusume-card {
  background: var(--ad);
  border: 1px solid #5b21b6;
  border-radius: 10px;
  padding: 8px 10px 9px;
}

.osusume-kicker {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 2px;
}

.osusume-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

.osusume-body {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.osusume-links {
  margin-top: 6px;
  font-size: 12px;
}

.osusume-link {
  color: #ddd6fe;
  word-break: break-all;
}

.osusume-sep {
  color: var(--muted);
}

.osusume-html {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
}

.osusume-html a {
  color: #ddd6fe;
}

.osusume-html img {
  display: block;
}

.osusume-html img[width="1"],
.osusume-html img[height="1"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

#display {
  flex: 1 1 auto;
  min-height: 140px;
  margin: 8px 10px;
  padding: 12px;
  resize: none;
  border: 0;
  border-radius: 12px;
  background: var(--display);
  color: var(--text);
  caret-color: #c4b5fd;
  font-family: "Roboto Mono", "Hiragino Sans", "Noto Sans JP", "Segoe UI", sans-serif;
  font-size: 18px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-all;
  overflow-y: auto;
  user-select: text;
  -webkit-user-select: text;
}

#display:focus {
  outline: 1px solid #6d28d980;
}

.pad {
  display: flex;
  flex: 0 0 auto;
  height: min(54lvh, 430px);
  gap: 6px;
  padding: 0 8px calc(8px + env(safe-area-inset-bottom));
}

.pad-main {
  flex: 1;
  display: grid;
  grid-template-rows: repeat(6, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
}

.pad-ops {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 18.5%;
  min-width: 56px;
}

.row-4,
.row-3 {
  display: grid;
  gap: 6px;
  min-height: 0;
}

.row-4 {
  grid-template-columns: repeat(4, 1fr);
}

.row-3 {
  grid-row: span 4;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, minmax(0, 1fr));
}

.pad button {
  appearance: none;
  border: 0;
  border-radius: 12px;
  background: var(--btn);
  color: var(--text);
  font: inherit;
  font-size: 22px;
  min-width: 0;
  width: 100%;
  height: 100%;
  padding: 0;
}

.pad-ops button {
  flex: 1;
  background: var(--btn-op);
  font-size: 24px;
}

.pad button:active {
  background: var(--btn-active);
}

.pad .key-ac {
  background: var(--accent-deep);
  font-weight: 700;
}

.pad .key-ac .key-sub {
  color: #ddd6fe;
}

.pad .key-ac.key-holding {
  filter: brightness(1.12);
}

.pad .key-ac:active {
  background: var(--accent);
}

.pad .key-subbed {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  line-height: 1;
}

.pad .key-main {
  font-size: 20px;
}

.pad .key-sub {
  font-size: 10px;
  color: var(--muted);
}

.pad .key-ans {
  font-size: 18px;
}

.pad button[data-act="digit"],
.pad button[data-act="dot"],
.pad button[data-act="paren"],
.pad .key-op {
  font-family: "Roboto Mono", ui-monospace, monospace;
}

.pad button[data-act="ac"],
.pad button[data-act="history"],
.pad button[data-act="ans"],
.pad button[data-act="up"],
.pad button[data-act="down"],
.pad button[data-act="left"],
.pad button[data-act="right"] {
  font-family: "Noto Sans JP", "Hiragino Sans", "Segoe UI", sans-serif;
}

.pad .key-bs {
  display: flex;
  align-items: center;
  justify-content: center;
}

.pad .key-bs img {
  display: block;
  width: 22px;
  height: 22px;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

#menu-root {
  position: fixed;
  inset: 0;
  z-index: 40;
}

#menu-root[hidden] {
  display: none;
}

.menu-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 4, 14, 0.62);
}

.menu-sheet {
  position: absolute;
  left: 8px;
  right: 8px;
  top: max(12px, env(safe-area-inset-top));
  bottom: max(12px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  background: #1c1526;
  border: 1px solid #3b2f4f;
  border-radius: 14px;
  overflow: hidden;
}

.menu-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 8px;
  border-bottom: 1px solid #3b2f4f;
}

.menu-title {
  flex: 1;
  margin: 0;
  font-size: 16px;
  text-align: center;
}

.menu-bar-btn {
  border: 0;
  background: transparent;
  color: #c4b5fd;
  font: inherit;
  font-size: 14px;
  padding: 6px 4px;
  min-width: 44px;
}

.menu-body {
  flex: 1;
  overflow: auto;
  padding: 12px 16px 24px;
  font-size: 14px;
  line-height: 1.65;
  color: #f3eefe;
  -webkit-overflow-scrolling: touch;
}

.menu-body h3 {
  margin: 1.2em 0 0.4em;
  font-size: 15px;
}

.menu-body p,
.menu-body ul {
  margin: 0.4em 0;
}

.menu-body a,
.menu-link {
  color: #ddd6fe;
}

.menu-link {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  text-decoration: underline;
}

.menu-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid #3b2f4f;
  background: transparent;
  color: #f3eefe;
  font: inherit;
  font-size: 16px;
  padding: 14px 4px;
  text-decoration: none;
}

.unlock-label,
.unlock-msg,
.trial-status {
  display: block;
  margin-top: 10px;
}

.unlock-input {
  width: 100%;
  margin-top: 4px;
  padding: 10px;
  border: 1px solid #5b21b6;
  border-radius: 8px;
  background: #16101f;
  color: #f3eefe;
  font: inherit;
}

.unlock-actions {
  margin-top: 10px;
}

.menu-btn {
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  color: #f3eefe;
  background: #7c3aed;
}

.menu-btn.ghost {
  background: #2a2138;
  margin-top: 8px;
}

.size-picks {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.size-pick {
  border: 1px solid #5b21b6;
  border-radius: 8px;
  padding: 12px 6px;
  background: #2a2138;
  color: #f3eefe;
  font: inherit;
}

.size-pick[aria-pressed="true"] {
  background: #7c3aed;
  border-color: #8b5cf6;
}

.op-picks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.op-pick {
  border: 1px solid #5b21b6;
  border-radius: 8px;
  padding: 12px 6px;
  background: #2a2138;
  color: #f3eefe;
  font: inherit;
}

.op-pick[aria-pressed="true"] {
  background: #7c3aed;
  border-color: #8b5cf6;
}

.about-hero {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.about-hero img {
  border-radius: 16px;
}

.about-name {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.about-ver {
  margin: 2px 0 0;
  color: #a394b8;
}
