      html {
        height: 100%;
      }

      body {
        --page-bg: #f4f4f4;
        --page-fg: #222222;
        --header-bg: #222222;
        --header-fg: #ffffff;
        --panel-bg: #ffffff;
        --panel-fg: #222222;
        --panel-border: #cccccc;
        --control-bg: #fafafa;
        --control-border: #dddddd;
        --field-bg: #ffffff;
        --hover-bg: #eeeeee;
        --muted-fg: #555555;
        --card-bg: #ffffff;
        --card-fg: #222222;
        --card-border: #222222;
        --scrollbar-track: transparent;
        --scrollbar-thumb: rgba(34, 34, 34, 0.24);
        --scrollbar-thumb-hover: rgba(34, 34, 34, 0.42);
        --header-height: 10vh;
        --score-area-height: 128px;
        --card-bottom-offset: 0px;
        height: 100vh;
        height: 100svh;
        margin: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        font-family: system-ui, sans-serif;
        color: var(--page-fg);
        background: var(--page-bg);
        overflow: hidden;
      }

      body.is-dark {
        --page-bg: #181818;
        --page-fg: #eeeeee;
        --header-bg: #111111;
        --header-fg: #f5f5f5;
        --panel-bg: #242424;
        --panel-fg: #eeeeee;
        --panel-border: #555555;
        --control-bg: #1f1f1f;
        --control-border: #555555;
        --field-bg: #181818;
        --hover-bg: #333333;
        --muted-fg: #bbbbbb;
        --scrollbar-thumb: rgba(238, 238, 238, 0.24);
        --scrollbar-thumb-hover: rgba(238, 238, 238, 0.44);
      }

      body,
      .panel {
        scrollbar-width: thin;
        scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
      }

      body::-webkit-scrollbar,
      .panel::-webkit-scrollbar {
        width: 10px;
        height: 10px;
      }

      body::-webkit-scrollbar-track,
      .panel::-webkit-scrollbar-track {
        background: var(--scrollbar-track);
      }

      body::-webkit-scrollbar-thumb,
      .panel::-webkit-scrollbar-thumb {
        background: var(--scrollbar-thumb);
        border: 3px solid transparent;
        border-radius: 999px;
        background-clip: content-box;
      }

      body::-webkit-scrollbar-thumb:hover,
      .panel::-webkit-scrollbar-thumb:hover {
        background: var(--scrollbar-thumb-hover);
        background-clip: content-box;
      }

      body::-webkit-scrollbar-corner,
      .panel::-webkit-scrollbar-corner {
        background: transparent;
      }

      header {
        position: relative;
        width: 100%;
        height: var(--header-height);
        min-height: 76px;
        padding: 10px 24px;
        box-sizing: border-box;
        flex-shrink: 0;
        background: var(--header-bg);
        color: var(--header-fg);
        text-align: left;
        overflow: hidden;
        user-select: none;
      }

      .header-resize-handle {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 40;
        height: 14px;
        padding: 0;
        border: 0;
        color: inherit;
        background: transparent;
        cursor: ns-resize;
        touch-action: none;
      }

      .header-resize-handle::before {
        content: "";
        position: absolute;
        left: 50%;
        top: 6px;
        width: 64px;
        height: 2px;
        transform: translateX(-50%);
        background: currentColor;
        border-radius: 2px;
        opacity: 0.38;
      }

      .header-resize-handle:hover::before,
      .header-resize-handle:focus-visible::before {
        opacity: 0.7;
      }

      .header-align-guide {
        position: absolute;
        z-index: 35;
        display: none;
        background: currentColor;
        opacity: 0.5;
        pointer-events: none;
      }

      .header-align-guide.is-visible {
        display: block;
      }

      .header-align-guide.is-vertical {
        top: 0;
        bottom: 0;
        width: 1px;
      }

      .header-align-guide.is-horizontal {
        left: 0;
        right: 0;
        height: 1px;
      }

      .header-box {
        position: absolute;
        min-width: 44px;
        min-height: 18px;
        padding: 2px 4px;
        box-sizing: border-box;
        display: flex;
        align-items: flex-start;
        overflow: hidden;
        border: 1px solid transparent;
        cursor: move;
        touch-action: none;
      }

      .header-box:hover,
      .header-box.is-selected {
        border-color: currentColor;
      }

      .header-box [data-header-text] {
        display: block;
        width: 100%;
        min-width: 0;
        max-height: 100%;
        overflow: hidden;
        overflow-wrap: anywhere;
        white-space: pre-wrap;
        word-break: break-word;
        pointer-events: none;
      }

      .header-logo-image {
        display: none;
        width: 100%;
        height: 100%;
        object-fit: contain;
        pointer-events: none;
      }

      .header-box.is-logo {
        align-items: stretch;
        padding: 4px;
      }

      .header-box.is-logo [data-header-text] {
        display: none;
      }

      .header-box.is-logo .header-logo-image {
        display: block;
      }

      .header-box-resize {
        position: absolute;
        right: 1px;
        bottom: 1px;
        width: 9px;
        height: 9px;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        opacity: 0;
        cursor: nwse-resize;
        pointer-events: auto;
      }

      .header-box:hover .header-box-resize,
      .header-box.is-selected .header-box-resize {
        opacity: 0.75;
      }

      .header-tournament {
        left: 2%;
        top: 10%;
        width: 30%;
        height: 32%;
        font-size: 20px;
        font-weight: 800;
        line-height: 1.15;
      }

      .header-rule {
        left: 2%;
        top: 50%;
        width: 30%;
        height: 28%;
        font-size: 13px;
        font-weight: 600;
        line-height: 1.2;
        opacity: 0.86;
      }

      .header-count {
        left: 42%;
        top: 31%;
        width: 10%;
        height: 38%;
        align-items: center;
        justify-content: center;
        text-align: center;
        font-size: 18px;
        font-weight: 800;
        line-height: 1;
      }

      .header-question {
        left: 54%;
        top: 15%;
        width: 42%;
        height: 34%;
        font-size: 15px;
        font-weight: 700;
        line-height: 1.2;
      }

      .header-answer {
        left: 54%;
        top: 56%;
        width: 42%;
        height: 28%;
        font-size: 13px;
        font-weight: 600;
        line-height: 1.2;
        opacity: 0.86;
      }

      main {
        flex: 1;
        min-height: 0;
        display: grid;
        place-items: stretch;
        width: 100%;
        padding: 12px 16px 28px;
        box-sizing: border-box;
      }

      .workspace {
        width: 100%;
        height: 100%;
        min-height: 0;
        display: grid;
        grid-template-columns: minmax(260px, 1fr) clamp(340px, 36vw, 480px);
        align-items: stretch;
        gap: 16px;
      }

      .preview-stack {
        justify-self: center;
        align-self: stretch;
        width: min(720px, 100%);
        min-height: 0;
        display: grid;
        grid-template-columns: auto minmax(260px, 1fr);
        align-items: start;
        gap: 14px;
      }

      .preview-stack > .card {
        justify-self: center;
        height: 100%;
      }

      .card {
        position: relative;
        width: 200px;
        height: 100%;
        min-height: 260px;
        padding: 12px 18px 24px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0;
        box-sizing: border-box;
        color: var(--card-fg);
        background: var(--card-bg);
        border: 2px solid var(--card-border);
        border-radius: 8px;
        overflow: hidden;
      }

      .maximize-note {
        display: none;
        width: 100%;
        padding: 8px 16px;
        box-sizing: border-box;
        background: #fff8e5;
        border-bottom: 1px solid #ead99d;
        color: #3b3214;
        font-size: 13px;
        font-weight: 700;
        text-align: center;
      }

      .maximize-note.is-visible {
        display: block;
      }

      .card-top {
        width: 100%;
        display: grid;
        gap: 2px;
        justify-items: center;
      }

      .rank {
        font-size: 18px;
        font-weight: 700;
      }

      .text {
        width: 100%;
        min-height: 18px;
        display: grid;
        place-items: center;
        font-size: 18px;
        line-height: 1.2;
        overflow: hidden;
        text-align: center;
        white-space: nowrap;
      }

      .rank[hidden],
      .text[hidden] {
        display: none !important;
      }

      .name {
        flex: 1;
        width: 100%;
        min-height: 0;
        display: grid;
        place-items: center;
        margin-top: 0;
        padding: 12px 0;
        box-sizing: border-box;
        overflow: hidden;
      }

      .name-text {
        writing-mode: vertical-rl;
        text-orientation: upright;
        font-size: 42px;
        font-weight: 700;
        line-height: 1;
        letter-spacing: 0;
        white-space: nowrap;
        max-height: 100%;
        max-width: 100%;
      }

      .score-area {
        width: 100%;
        height: var(--score-area-height);
        min-height: 64px;
        padding: 8px 0 10px;
        position: relative;
        border-top: 1px solid currentColor;
        box-sizing: border-box;
      }

      .roster-preview-card {
        width: var(--roster-card-width, 100%);
        max-width: 100%;
        height: var(--roster-card-height, 104px);
        padding: var(--roster-padding-y, 8px) var(--roster-padding-x, 12px) calc(var(--roster-padding-y, 8px) + 2px);
        display: grid;
        grid-template-rows: auto var(--roster-divider-size, 1px) minmax(0, 1fr);
        gap: var(--roster-gap, 7px);
        box-sizing: border-box;
        color: var(--card-fg);
        background: var(--card-bg);
        border: 2px solid var(--card-border);
        border-radius: var(--roster-card-radius, 8px);
        overflow: hidden;
      }

      .roster-preview-card.is-divider-hidden {
        grid-template-rows: auto minmax(0, 1fr);
      }

      .roster-preview-card.is-rank-hidden {
        grid-template-rows: minmax(0, 1fr);
      }

      .roster-preview-rank {
        min-width: 0;
        overflow: hidden;
        color: currentColor;
        font-size: var(--roster-rank-size, 14px);
        font-weight: var(--roster-rank-weight, 800);
        line-height: 1.05;
        text-align: var(--roster-rank-align, center);
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .roster-preview-divider {
        width: 100%;
        height: var(--roster-divider-size, 1px);
        background: var(--roster-divider-color, currentColor);
        opacity: var(--roster-divider-opacity, 0.72);
      }

      .roster-preview-name-area {
        position: relative;
        min-width: 0;
        min-height: 0;
        display: grid;
        align-items: center;
        justify-items: var(--roster-name-justify, center);
        overflow: hidden;
      }

      .roster-preview-name {
        position: absolute;
        top: 50%;
        left: 50%;
        width: max-content;
        max-width: none;
        font-size: var(--roster-name-size, 30px);
        font-weight: var(--roster-name-weight, 900);
        line-height: 1;
        letter-spacing: 0;
        text-align: var(--roster-name-align, center);
        white-space: nowrap;
      }

      .score-resize-handle {
        position: absolute;
        left: 0;
        top: -10px;
        width: 100%;
        height: 20px;
        border: 0;
        padding: 0;
        background: transparent;
        cursor: ns-resize;
        touch-action: none;
        z-index: 6;
      }

      .score-resize-handle::before {
        content: "";
        position: absolute;
        left: 50%;
        top: 7px;
        width: 44px;
        height: 4px;
        transform: translateX(-50%);
        background: currentColor;
        border-radius: 2px;
        opacity: 0.45;
      }

      .score-layer {
        width: 100%;
        height: 100%;
        display: grid;
        grid-template-columns: repeat(13, minmax(0, 1fr));
        grid-template-rows: repeat(25, minmax(0, 1fr));
        user-select: none;
        pointer-events: none;
        z-index: 3;
      }

      .score-number {
        display: grid;
        place-items: center;
        justify-self: center;
        align-self: center;
        width: max-content;
        min-width: 0;
        font-size: 36px;
        font-weight: 700;
        line-height: 1;
        white-space: nowrap;
        text-align: center;
        cursor: grab;
        pointer-events: auto;
        touch-action: none;
        user-select: none;
        z-index: 2;
      }

      .score-number.is-selected {
        outline: 2px solid currentColor;
        outline-offset: 2px;
      }

      /* 複数選択中の主選択（設定欄に出ている部品）は破線で区別する。 */
      .score-number.is-primary-selected {
        outline-style: dashed;
        outline-width: 3px;
      }

      .score-number:active {
        cursor: grabbing;
      }

      .panel {
        width: 100%;
        height: 100%;
        min-height: 0;
        max-height: none;
        overflow-x: hidden;
        overflow-y: auto;
        padding: 4px 0 4px 16px;
        scrollbar-gutter: stable;
        display: grid;
        align-content: start;
        gap: 18px;
        box-sizing: border-box;
        color: var(--panel-fg);
        background: transparent;
        border-left: 1px solid var(--panel-border);
        border-radius: 0;
      }

      @media (max-width: 760px) {
        body {
          overflow: auto;
        }

        header {
          min-height: 104px;
          padding: 10px 16px;
        }

        .header-box {
          min-width: 38px;
          min-height: 18px;
        }

        .workspace {
          height: auto;
          grid-template-columns: 1fr;
        }

        .preview-stack {
          min-height: 72vh;
          grid-template-columns: 1fr;
          grid-template-rows: minmax(260px, auto) auto;
        }

        .preview-stack > .card {
          height: max(260px, calc(52vh - var(--card-bottom-offset)));
          max-height: 680px;
        }

        .panel {
          height: auto;
          max-height: none;
          padding: 16px 0 0;
          border-left: 0;
          border-top: 1px solid var(--panel-border);
          overflow-x: hidden;
          overflow-y: visible;
        }
      }

      .panel label {
        min-width: 0;
        display: grid;
        gap: 6px;
        font-size: 12px;
        font-weight: 700;
        color: var(--panel-fg);
      }

      .panel input,
      .panel select,
      .panel button {
        min-width: 0;
        max-width: 100%;
        font: inherit;
      }

      .panel input[type="text"],
      .panel input[type="number"],
      .panel input[type="file"],
      .panel select {
        width: 100%;
        padding: 8px 10px;
        box-sizing: border-box;
        color: var(--panel-fg);
        background: var(--field-bg);
        border: 1px solid var(--panel-border);
        border-radius: 6px;
        outline: none;
      }

      .panel input[type="text"]:focus,
      .panel input[type="number"]:focus,
      .panel input[type="file"]:focus,
      .panel select:focus {
        border-color: var(--panel-fg);
      }

      .panel input[type="range"] {
        width: 100%;
        accent-color: var(--panel-fg);
      }

      .panel input[type="checkbox"] {
        width: 16px;
        height: 16px;
        accent-color: var(--panel-fg);
      }

      .panel input[type="color"] {
        width: 100%;
        height: 34px;
        padding: 2px;
        background: var(--field-bg);
        border: 1px solid var(--panel-border);
        border-radius: 6px;
      }

      .panel-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding-bottom: 10px;
        border-bottom: 1px solid var(--panel-border);
      }

      .panel-title {
        margin: 0;
        font-size: 16px;
        font-weight: 700;
      }

      .reset-button {
        padding: 6px 10px;
        color: var(--panel-fg);
        background: var(--field-bg);
        border: 1px solid var(--panel-border);
        border-radius: 6px;
        cursor: pointer;
      }

      .reset-button:hover {
        background: var(--hover-bg);
      }

      .control-section {
        min-width: 0;
        display: grid;
        gap: 12px;
        padding: 0 0 18px;
        background: transparent;
        border: 0;
        border-bottom: 1px solid var(--control-border);
        border-radius: 0;
      }

      .section-title {
        margin: 0;
        color: var(--muted-fg);
        font-size: 11px;
        font-weight: 800;
        letter-spacing: 0;
      }

      .button-row {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
      }

      .score-add-row {
        grid-template-columns: repeat(5, minmax(0, 1fr));
      }

      .settings-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }

      .button-row button {
        min-height: 34px;
        color: var(--panel-fg);
        background: var(--field-bg);
        border: 1px solid var(--panel-border);
        border-radius: 6px;
        cursor: pointer;
      }

      .button-row button:hover {
        background: var(--hover-bg);
        border-color: var(--muted-fg);
      }

      .toggle-row {
        display: flex;
        grid-template-columns: none;
        align-items: center;
        gap: 8px;
      }

      .toggle-row input {
        margin: 0;
      }

      .control-title {
        margin: 0 0 -6px;
        color: var(--muted-fg);
        font-size: 11px;
        font-weight: 700;
      }

      .color-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
      }

      .score-preview-list {
        display: grid;
        gap: 6px;
      }

      .score-preview-row {
        display: grid;
        grid-template-columns: 24px 1fr;
        align-items: center;
        gap: 6px;
      }

      .score-preview-row span {
        padding: 5px 0;
        color: var(--panel-fg);
        background: var(--hover-bg);
        border-radius: 6px;
        font-size: 13px;
        font-weight: 700;
        text-align: center;
      }

      .control-label-line {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
      }

      .panel input.control-value {
        width: 64px;
        padding: 4px 6px;
        color: var(--panel-fg);
        font-size: 12px;
        font-weight: 800;
        text-align: right;
      }

      .header-style-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
      }

      .settings-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }

      .settings-status {
        min-height: 1.4em;
        margin: -4px 0 0;
        color: var(--muted-fg);
        font-size: 12px;
        line-height: 1.4;
      }

      .settings-status.is-error {
        color: #b00020;
      }
    
