Greasy Fork is available in English.

Typing Tube MOD official

try to take over the world!

Pasang skrip ini?
Sugesti pemilik skrip

Kamu mungkin juga suka rgba color picker.

Pasang skrip ini
    // ==UserScript==

//タイピングワード表示の処理高速化・不具合修正・MODの処理最適化ため

//プレイ中の処理
//playheadupdate()、keydownfunc(event)、keypressfunc_kana()、keydownfunc_kana(),clearForNextString()、update_status()、checkNextChar()、checkNextKana()

//プレイ前準備処理
//onPlayerReady()、parseRomaMap(),parseLyrics(),hiraganaToRomaArray()、getScorePerChar()、onPlayerStateChange()


//プレイ終了時処理
//stop_movie(),finish_movie()

//以上の関数を書き換えています。
//このスクリプトの適応時は書き換えた関数が優先して発動されているので注意をお願いします。


// @name         Typing Tube MOD official
// @namespace    https://typing-tube.net/
// @version      31.1.9
// @description  try to take over the world!
// @author       Toshi
// @match        https://typing-tube.net/movie/show/*?*test=test*
// @match        https://typing-tube.net/movie/typing/*?*test=test*
// @noframes
// @run-at document-end


// ==/UserScript==




document.getElementById("modal-open").classList.add('no_select'); //曲情報にcss追加




/////////////////////////////////////////////////////////////////////////////////////////////////
/**
*@ページを開いたときのMOD追加機能処理 ここから---
*/


(function add_dom(){
//設定を追加
add_css()
var setting_html = document.createElement('form');
    setting_html.setAttribute("id", "mod_setting");
    setting_html.setAttribute("style", "color:#fff; z-index:100;display:none;position:fixed;word-break: break-all;width:580px;max-height: 900px;background-color: rgba(0,0,0,0.96);");
    setting_html.innerHTML='<input id="all" type="radio" name="tab_item" checked><label class="tab_item" for="all">プレイ設定</label><input id="design" type="radio" name="tab_item"><label class="tab_item" for="design">エフェクト設定</label><input id="playcolor" type="radio" name="tab_item"><label class="tab_item" for="playcolor">配色設定</label><input id="etc" type="radio" name="tab_item"><label class="tab_item" for="etc">ステータス設定</label>'+
'<div class="tab_content" id="all_content"><div class="tab_content_description"><p class="c-txtsp">'+
'<button type="button" id="osusume" style="position:absolute;right:130px;bottom:10px;">おすすめ設定</button>'+
'<h6 style="float:left;">入力モード設定</h6><input id="page1" type="radio" name="input_page"checked><label class="input_page" for="page1"><Page1</label><input id="page2" type="radio" name="input_page"><label class="input_page" for="page2">Page2></label>'+
'<div class="page_content" id="page1_content"><div class="page_content_description"><p class="c-txtsp">'+
'<label title="かな表示モードは大文字ローマ字。ローマ字表示モードはかな表示が表示されます。"><input type="checkbox" value="sub"checked>ローマ字orひらがなも表示</input></label><br><label title="促音→「った」を[ltuta.xtuta]。拗音→「しゃ」を[silya,sixya]。等の手間がかかる入力パターンを無効化します。少ない打鍵数で入力したい方におすすめです。"><input type="checkbox" value="mizumasi">促音・拗音の入力パターンを最適化</label><br><label title="2文字以上ある英数字・記号を先頭の文字色とアンダーラインでハイライトさせます。"><input type="checkbox" value="eng_highlight">英数字をハイライト(かな表示のみ)</input></label><br>'+
'</p></div></div>'+
'<div class="page_content" id="page2_content"><div class="page_content_description"><p class="c-txtsp">'+
'<label title="タイピングワードが一行に収まるように表示され、指定した文字数入力するとワードがスクロールされていきます。"><input type="checkbox" value="letter_scroll">タイピングワードをスクロール表示</input></label><br><span class="scroll_amount"><span style="margin-left:13px;">└</span><label><input type="number"name="letter_scroll_kana"min="0" max="30"value="10">かな表示スクロール数</input></label><label><input type="number"name="letter_scroll_roma"min="0" max="30" value="16">ローマ字表示スクロール数</input></label></span>'+
'<label title="タイピングデータにスペース・記号系が含まれていても、こちらの設定を変更することで省略できます。変更後はページを更新してください。"><input type="checkbox" value="word_disable">スペース・記号を省略する</label><span id=word_making style=display:none;><span style="margin-left:13px;">└</span><label title="スペースの入力を省略します"><input type="checkbox" value="space_disable">スペース</label><label title="記号の入力を省略します"><input type="checkbox" value="kigou_disable">記号(長音記号「ー~」は除く)</label></span>'+
'<label title="アルファベット大文字をSHIFT有り+アルファベット。アルファベット小文字をSHIFT無し+アルファベットで入力できるようにします。有効にした場合は一度ページを更新してください。" style=display:block;><input type="checkbox" value="oomoji_shift">アルファベット入力でSHIFTキーを使用する</label>'+
'</p></div></div>'+
'<h6>制限モード</h6><label title="次の歌詞とライン経過時間を隠します。いきなり現れた文字を瞬時に入力するスキルを鍛えることができます。"><input type="checkbox" value="line_hidden">初速測定モード</input></label><br><label title="正確率に制限をかけるモードです。指定した正確率より下回ると動画が強制終了します。タイピングの正確性を上げる目標設定です。"><input type="checkbox" value="perfect_mode">ミス制限モード</input></label><label class="miss_limit">目標正確率<input type="number"name="miss_limit" value="95" min="0" max="100">%</input><label title="目標正確率を下回った瞬間にゲームオーバーになります。玄人向け"><input type="radio" name=miss_limit_mode value="keep_corrent">正確率を維持</input></label><label title="目標正確率を達成する為のライフがstatusに表示されます。タイピングワードを逃す程ライフが減り、1ミスすると-1点されます。ライフがマイナスになると、目標正確率は達成不可能になりゲームオーバーになります。"><input type="radio" name=miss_limit_mode value="life_corrent" checked>ライフ制</input></label><label title="ゲームオーバーすると効果音が鳴るようになります。"><input type="checkbox" value="gameover_sound" checked>ゲームオーバー音</input></label><label><input type="number"name="effect_volume_gameover"min="0" max="100" value="70"></input></label></label>'+
'<h6>効果音・音量</h6><label title="正解打鍵をした時に効果音がなるようになります。"><input type="checkbox" value="type_sound">打鍵音</input></label><label><input type="number"name="effect_volume_type"min="0" max="100" value="70"></input></label><label title="ミス打鍵をした時に効果音がなるようになります。"><input type="checkbox" value="miss_sound">ミス音</input></label><label title="行頭のミス打鍵時もミス音を鳴らします" id="miss_top_checkbox" style="display:none;"><input type="checkbox" value="miss_sound_top">行頭のミス音</input></label><label><input type="number"name="effect_volume_miss"min="0" max="100" value="70"></input></label><br><label title="ライン中のタイピングワードをすべて入力した時に効果音がなるようになります。"><input type="checkbox" value="clear_sound">クリア音</input></label><label><input type="number"name="effect_volume_clear"min="0" max="100" value="70"></input></label><label title="100コンボ以上コンボが続いている時にミスをすると、効果音が鳴るようになります"><input type="checkbox" value="combo_break_sound">100コンボ以上のミス音</input></label><label><input type="number"name="effect_volume_combo_break"min="0" max="100" value="70"></input></label><br><label title="動画音量に合わせて効果音音量も変更されます。無効にすると効果音毎で個別に音量指定ができます。"><input type="checkbox" value="Interlocking_volume"checked>曲音量と効果音音量を連動</input></label>'+
'<br></p></div></div>'+
'<div class="tab_content" id="design_content"><div class="tab_content_description"><p class="c-txtsp">'+
'<h6>エフェクト設定</h6><label title="ミスをした文字の上に「・」マークが表示されます。"><input type="checkbox" value="miss_on"checked>ミスエフェクト</label><label><input class="color" value="#FF3554" name="miss_color">色で表示</label><br><label title="3・2・1・GO!のカウントダウンが表示されます。間奏中にも歌詞がある場合は表示されません。"><input type="checkbox" value="anime_count" checked>間奏終了前にカウントダウン</label><label><input class="color" value="rgba(255,255,255,0.9)" name="countdown_color">色で表示</label><label title="カウントダウンが秒数ごとにフィードアウトされるようになります。"><input type="checkbox" value="count_animation" checked>アニメーション</label><br><label title="スキップ可能な時に「Type ~ key to skip. ⏩」と表示されるようになります。表示されているときにスペースキー又はEnterキーを押すとライン切り替わり1秒前にスキップします。"><input type="checkbox" value="skip_guide" checked>任意スキップ</label><label><input class="color" value="rgba(255,255,255,0.53)" name="skipguide_color">色で表示</label><label title="スキップ機能で使用するキーをスペースキーにします。"><input type="radio" name=skip_button value="skip_space" checked>スペースキー</label><label title="スキップ機能で使用するキーをEnterキーにします。" style="margin-left:0;"><input type="radio" name=skip_button value="skip_enter">Enterキー</label><br><label title="タイピングワードの上部に現在コンボを表示します。この機能を有効にし、ステータス設定のコンボ表示をOFFにするのもおすすめです"><input type="checkbox" value="combo_display">現在コンボを表示</label><label><input class="color" value="#FFFFFF" name="combo_color">色で表示</label><label title="コンボが更新される度、コンボ数が前面に押し出されたように表示されます。"><input type="checkbox" value="combo_animation" checked>アニメーション</label><br><label title="動画下にラインクリア率ゲージを表示します。達成したクリア率に応じた色のトロフィーも表示されます。"><input type="checkbox" value="gauge" >ラインクリア率ゲージを表示(デモ)</input></label><br><button style="margin:10px" type="button" id="effectcolor_reset">エフェクト色をリセット</button>'+
'<h6>フォント設定</h6><label><input type="number"name="font_size_kana"min="1" max="25" step="0.5" value="17.5">かな表示フォントサイズ</input></label><label><input type="number"name="font_size_roma"min="0" max="25" step="0.5" value="17.5">ローマ字表示フォントサイズ</input></label>'+
'<br><h6>歌詞の色/表示</h6><label>入力後<input class="color" value="#0099CC" name="correctword_color"></label><label>ラインクリア<input class="color" value="#1eff52" name="lineclear_color"></label><label>先頭の文字<input class="color" value="#FFFFFF" name="first_color"></label><label>未入力<input class="color" value="#FFFFFF" name="word_color"></label><br><label>歌詞<input class="color" value="#FFFFFF" name="lyric_color"></label><label>次の歌詞<input class="color" value="rgba(255,255,255,.7)" name="next_lyrics_color"></label><label title="次の歌詞に通常の歌詞を表示します。"><input type="radio" name=next_text value="next_text_lyric"checked>歌詞</input></label><label title="次の歌詞に実際に入力する文字(歌詞のふりがな)を表示します"><input type="radio" name=next_text value="next_text_reading">よみ</input></label>'+
'<br><select style="margin:10px" name="color_theme"><option value="プリセット">プリセットから色変更</option><option value="デフォルト">デフォルト</option><option value="先頭の文字を赤く強調">先頭の文字を赤く強調</option></select>'+
'<br></p></div></div>'+
'<div class="tab_content" id="playcolor_content"><div class="tab_content_description"><p class="c-txtsp">'+
'<h6>背景カラー</h6><label><input class="color" value="transparent" name="playarea_color"id="input2"></label><label><input type="number" name="playarea_radius" min="0" max="30" value="0"step="1">px</input>縁を丸める</label><br>'+
'<label>縁取り線<select name="futidori_theme"><option value="none" selected>なし</option><option value="solid">1本線</option><option value="double">2本線</option><option value="groove">立体線(窪む)</option><option value="ridge">立体線(隆起)</option><option value="outset">立体線(影)</option><option value="dashed">破線</option><option value="dotted">点線</option></select></label><label>縁の色<input class="color" value="#FFFFFF" name="futidori_color"></label><label>太さ<select name="futidori_border-width"><option value="medium" selected>普通</option><option value="thin">細い</option><option value="thick">太い</option></select></label><br><button type="button" id="playareacolor_reset" class="m-3">背景カラーをリセット</button><br>'+
'<h6>ラインカラー</h6><label>ラインゲージ<input class="color" value="#17a2b8" name="line_color"></label><label>empty<input class="color" value="#f5f5f5" name="line_empty_color"></label><br><label>ラインゲージ2<input class="color" value="#ffc107" name="line_color2"></label><label>empty<input class="color" value="#f5f5f5" name="line_empty_color2"></label><br><button type="button" id="linecolor_reset" class="m-3">ラインカラーをリセット</button>'+
'<h6>ステータス/コントロール文字色</h6><label>ステータス<input class="color" value="#FFFFFF" name="status_color"></label><label>自分の色<input class="color" value="#20c997" name="me_color"></label><br><label>コントロール<input class="color" value="rgba(255,255,255,.85);" name="control_color"></label><br><button type="button" id="subtextcolor_reset" class="m-3">ステータス/コントロール文字色をリセット</button>'+
'<br></p></div></div>'+
'<div class="tab_content" id="etc_content"><div class="tab_content_description"><p class="c-txtsp">'+
'<h6>プレイ前設定</h6><label title="プレイ中に変更できる時間調整の初期値を変更します。打ち始めのタイミングが合わないときは、+0.1~+0.2程タイミングを早めるのもおすすめです">時間調整オフセット<span class="btn btn-link" title="タイミングが遅くなります。SHIFTキーを押しながらクリックすると-0.1します。" style="cursor: pointer"id="initial_diff_minus">-</span><span id="initial_diff"></span><span class="btn btn-link" title="タイミングが早くなります。SHIFTキーを押しながらクリックすると+0.1します。" style="cursor: pointer"id="initial_diff_plus">+</span></label><button type="button" id="initial_diff_reset">初期値に戻す</button>'+
'<br><label title="プレイ開始前に決める挑戦速度の初期値を変更します。この値を変更するとLv1の挑戦速度が変更されます。">Lv1の挑戦速度<span class="btn btn-link" title="Lv1の動画が遅くなります" style="cursor: pointer"id="initial_speed1_down">-</span><span id="initial_speed1">1.00</span><span class="btn btn-link" title="Lv1の動画が速くなります" style="cursor: pointer"id="initial_speed1_up">+</span></label>'+
'<label title="プレイ開始前に決める挑戦速度の初期値を変更します。この値を変更するとLv2の挑戦速度が変更されます。">Lv2の挑戦速度<span class="btn btn-link" title="Lv2の動画が遅くなります" style="cursor: pointer"id="initial_speed2_down">-</span><span id="initial_speed2">1.00</span><span class="btn btn-link" title="Lv2の動画が速くなります" style="cursor: pointer"id="initial_speed2_up">+</span></label>'+
'<br><label title="プレイ開始前に決める挑戦速度の初期値を変更します。この値を変更するとLv3の挑戦速度が変更されます。">Lv3の挑戦速度<span class="btn btn-link" title="Lv3の動画が遅くなります" style="cursor: pointer"id="initial_speed3_down">-</span><span id="initial_speed3">1.00</span><span class="btn btn-link" title="Lv3の動画が速くなります" style="cursor: pointer"id="initial_speed3_up">+</span></label>'+
'<label title="プレイ開始前に決める挑戦速度の初期値を変更します。この値を変更するとLv4の挑戦速度が変更されます。">Lv4の挑戦速度<span class="btn btn-link" title="Lv4の動画が遅くなります" style="cursor: pointer"id="initial_speed4_down">-</span><span id="initial_speed4">1.00</span><span class="btn btn-link" title="Lv4の動画が速くなります" style="cursor: pointer"id="initial_speed4_up">+</span></label>'+
'<label title="プレイ開始前に決める挑戦速度の初期値を変更します。この値を変更するとLv5の挑戦速度が変更されます。">Lv5の挑戦速度<span class="btn btn-link" title="Lv5の動画が遅くなります" style="cursor: pointer"id="initial_speed5_down">-</span><span id="initial_speed5">1.00</span><span class="btn btn-link" title="Lv5の動画が速くなります" style="cursor: pointer"id="initial_speed5_up">+</span></label><br><button type="button" class="m-3" id="initial_speed_reset">初期値に戻す</button><br>'+
'<label title="プレイ開始時やプレイ中の拡大値を変更したとき、自動でプレイエリアにスクロール位置が調整されます。プレイ開始時は画面内に動画が表示されていないと発動されません。"><input type="checkbox" value="play_scroll">プレイ開始時スクロール位置を調整</input></label><br><span class="adjustment"><span style="margin-left:13px;">└</span>'+
'<select name="scroll_adjustment1"><option value="55" selected>中央</option><option value="75">上部</option><option value="-10">下部</option></select><label title="プレイ中動画を非表示にします。動画自体は読み込まれているので通信を抑える効果はありません。"><input type="checkbox" value="not_video">動画を隠す</input></label></span>'+
'<h6>status表示設定</h6><label title="歌詞タイピングエリアを左側、status/rankingエリアを右側に表示します。歌詞タイピングエリアは狭くなりますが動画全体も表示しやすくなります。"><input type="radio" name=status_mode value="status_mode_not_break"checked>折り返さない</input></label>'+
'<label title="歌詞タイピングエリアを上部全体で表示、status/rankingエリアを下部に表示します。動画が見切れやすくなりますが歌詞タイピングエリアが広くなりプレイしやすくなります。"><input type="radio" name=status_mode value="status_mode_new_line">折り返す</input></label><br>'+
'<input id="details" type="checkbox" name="details"><label class="details" for="details">詳細設定</label><div class="details_content"id="details_content"><label><input type="checkbox" value="score"checked>スコア</input></label><label><input type="checkbox" value="miss"checked>ミス</input></label><label><input type="checkbox" value="acc"checked>正確率</input></label><br><label><input type="checkbox" value="combo_counter"checked>コンボ</input></label><label><input type="checkbox" value="type_counter"checked>正解打鍵</input></label><label><input type="checkbox" value="escape_counter"checked>逃した文字数</input></label><br><label><input type="checkbox" value="clear_counter"checked>ラインクリア</input></label>'+
'<label><input type="checkbox" value="line_count"checked>残りライン</input></label><br><label><input type="checkbox" value="rank"checked>現在の順位</input></label><label><input type="checkbox" value="typing_speed"checked>打鍵速度</input></label></div>'+
'<h6>リザルト設定</h6><label><input type="radio" name=word_result_display value="word_result"checked>ミスをした箇所を赤く表示</input></label><label><input name=word_result_display type="radio" value="word_result_real">ミスをした文字も詳細に表示</input></label>'+
'<br></p></div></div>'+
'<button type="button" id="setting_reset" style="position:absolute;right:10px;bottom:10px;">設定をリセット</button>'
document.getElementsByClassName("share")[0].parentNode.insertBefore(setting_html , document.getElementsByClassName("share")[0].nextElementSibling);
facog_check()

var gauge_html = document.createElement('div');
    gauge_html.setAttribute("id", "gauge");
    gauge_html.setAttribute("style", "display:none;");
    gauge_html.innerHTML = '<div class="progress2" id="gauge1" style="width: 80%;float: left;height:8px;"><div id="clear_gauge"></div></div><div class="progress2" id="gauge2" style="width: 20%;background: #4E3701;height:12px;"><span style="height: 5px;border-left: thin #FFEB3B solid;"></span><div id="clear_gauge2"></div></div><div id="clear_percent" style="font-weight: normal;color: #fff;text-align: right;width: 0px;float: right;position: relative;top: -26px;left: 3px;font-size: 1.4rem;font-family: sans-serif;">0%</div>'
document.getElementById("controlbox").parentNode.insertBefore(gauge_html, document.getElementById("controlbox"));

var f10_html = document.createElement('span')
    f10_html.textContent = "(F10)";
document.getElementById("speed").parentNode.insertBefore(f10_html , document.getElementById("speed").nextElementSibling);

var start_html = document.createElement('div');
    start_html.setAttribute("id", "esckey");
    start_html.textContent = "Enterキー / 動画をクリックして開始"
document.getElementById("playBotton1").parentNode.insertBefore(start_html, document.getElementById("playBotton1"));

document.querySelector("#playBotton1 > .col-6").innerHTML = '<label style="margin-bottom:0!important;"><input  type="radio" name=mode_select value="kana_type"checked>Play - かな表示</label>';
document.querySelector("#playBotton2 > .col-6").innerHTML = '<label style="margin-bottom:0!important;"><input  type="radio" name=mode_select value="roma_type">Play - ローマ字表示</label>';

if(document.getElementById("playBotton4") != null){//かな入力モードがあれば処理
document.querySelector("#playBotton4 > .col-6").innerHTML = '<label style="margin-bottom:0!important;"><input  type="radio" name=mode_select value="kanamode_type">Play - かな入力<span style="font-size:50%">(106/109)</span></label>';
document.querySelector("#playBotton5 > .col-6").innerHTML = '<label style="margin-bottom:0!important;"><input  type="radio" name=mode_select value="kanamode_mac_type">Play - かな入力<span style="font-size:50%">(Mac用JIS)</span></label>';
}

}());


function facog_check(){
if(document.getElementsByClassName("fa-cog")[0] ==null){
var cog_html= document.createElement('a');
    cog_html.setAttribute("class", "btn");
    cog_html.setAttribute("style", "font-size:24px;");
    cog_html.innerHTML = '<i class="zmdi-hc-fw zmdi fas fa-cog" title="オプション"></i>'
document.getElementsByClassName("twitter")[0]
document.getElementsByClassName("twitter")[0].parentNode.insertBefore(cog_html, document.getElementsByClassName("twitter")[0]);
}
var mod_menu_open_flag = false
document.getElementsByClassName("fa-cog")[0].addEventListener('mousedown', function(){
if(!mod_menu_open_flag){
mod_menu_event()
mod_menu_open_flag = true
}
document.getElementById("modal-overlay").style.display = "block";

    //コンテンツをセンタリングする
document.getElementById("mod_setting").style.display = "block";
    centering();

document.getElementById("mod_setting").animate([{opacity: '0'}, {opacity: '1'}], 100)
document.getElementById("modal-overlay").addEventListener('mousedown', function(){

document.getElementById("modal-overlay").style.display = "none";
document.getElementById("mod_setting").style.display = "none";

    });
document.getElementById("modal-overlay").addEventListener('touchstart', function(){

document.getElementById("modal-overlay").style.display = "none";
document.getElementById("mod_setting").style.display = "none";

    });
});
window.addEventListener('resize', centering);

}


//MOD設定メニュー位置調整する関数
function centering(){
//画面(ウィンドウ)の幅、高さを取得
var w = window.innerWidth;
var h = window.innerHeight;
// コンテンツ(#mod_setting)の幅、高さを取得
var cw = document.getElementById("mod_setting").offsetWidth;
var ch = document.getElementById("mod_setting").offsetHeight;
//センタリングを実行する
document.getElementById("mod_setting").style.left = ((w - cw))+ "px";
document.getElementById("mod_setting").style.top = ((h - ch)/4.4) + "px";
}



var initial_speed=[] //ローカルストレージの難易度毎のスピード設定取得配列
var initial_diff=0.0 //ローカルストレージに保存された時間調整値
var initial_speed1=1.0 //Lv1のスピード変更設定値
var initial_speed2=1.0 //Lv2のスピード変更設定値
var initial_speed3=1.0 //Lv3のスピード変更設定値
var initial_speed4=1.0 //Lv4のスピード変更設定値
var initial_speed5=1.0 //Lv5のスピード変更設定値

//MOD設定メニュー項目変更時に呼び出すイベント集
function mod_menu_event(){
//設定リセット関数
checkbox_effect_mod_open_play()

document.getElementById("setting_reset").addEventListener('click', function (){
    var res = confirm("全てのチェックボックス・効果音音量・スクロール量を初期設定に戻します。よろしいですか?");
    if( res == true ) {
document.querySelector("[value=next_text_lyric]").checked = true;
document.querySelector("[value=center]").checked = true;
document.querySelector("[value=line_count]").checked = true;
document.querySelector("[value=rank]").checked = true;
document.querySelector("[value=typing_speed]").checked = true;
document.querySelector("[value=escape_counter]").checked = true;
document.querySelector("[value=status_mode_not_break]").checked = true;
document.querySelector("[value=skip_space]").checked = true;
document.querySelector("[value=miss_on]").checked = true;
document.querySelector("[value=gameover_sound]").checked = true;
document.querySelector("[value=anime_count]").checked = true;
document.querySelector("[value=sub]").checked = true;
document.querySelector("[value=Interlocking_volume]").checked = true;
document.querySelector("[value=skip_guide]").checked = true;
document.querySelector("[value=score]").checked = true;
document.querySelector("[value=miss]").checked = true;
document.querySelector("[value=acc]").checked = true;
document.querySelector("[value=combo_counter]").checked = true;
document.querySelector("[value=type_counter]").checked = true;
document.querySelector("[value=clear_counter]").checked = true;
document.querySelector("[value=gauge]").checked = false;
document.querySelector("[value=play_scroll]").checked = false;
document.querySelector("[value=not_video]").checked = false;
document.querySelector("[value=word_disable]").checked = false;
document.querySelector("[value=oomoji_shift]").checked = false;
document.querySelector("[value=mizumasi]").checked = false;
document.querySelector("[value=perfect_mode]").checked = false;
document.querySelector("[value=combo_animation]").checked = false;
document.querySelector("[value=letter_scroll]").checked = false;
document.querySelector("[value=line_hidden]").checked = false;
document.querySelector("[value=eng_highlight]").checked = false;
document.querySelector("[value=type_sound]").checked = false;
document.querySelector("[value=miss_sound]").checked = false;
document.querySelector("[value=miss_sound_top]").checked = false;
document.querySelector("[value=clear_sound]").checked = false;
document.querySelector("[value=combo_break_sound]").checked = false;
document.querySelector("[value=combo_display]").checked = false;


document.querySelector("[name=effect_volume_type]").value = 70;
document.querySelector("[name=effect_volume_miss]").value = 70;
document.querySelector("[name=effect_volume_clear]").value = 70;
document.querySelector("[name=effect_volume_gameover]").value = 70;
document.querySelector("[name=letter_scroll_roma]").value = 16;
document.querySelector("[name=letter_scroll_kana]").value = 10;
document.querySelector("[name=font_size_kana]").value = 17.5;
document.querySelector("[name=font_size_roma]").value = 17.5;
setting_save()
checkbox_effect()
checkbox_effect_play()
checkbox_effect_mod_open_play()
}
});


document.getElementById("effectcolor_reset").addEventListener('click', function (){
    var res = confirm("エフェクト色をデフォルトに戻します。よろしいですか?");
    if( res == true ) {
document.querySelector("[name=miss_color]").value = "#FF3554"
document.querySelector("[name=miss_color]").style.backgroundColor="rgb(255, 53, 84)"
document.querySelector("[name=miss_color]").style.color="rgb(255, 255, 255)"

document.querySelector("[name=countdown_color]").value = "rgba(255,255,255,0.9)"
document.querySelector("[name=countdown_color]").style.backgroundColor="rgba(255,255,255,0.9)"
document.querySelector("[name=countdown_color]").style.color="rgb(0, 0, 0)"

document.querySelector("[name=skipguide_color]").value = "rgba(255,255,255,0.53)"
document.querySelector("[name=skipguide_color]").style.backgroundColor="rgba(255,255,255,0.53)"
document.querySelector("[name=skipguide_color]").style.color="rgb(0, 0, 0)"

document.querySelector("[name=combo_color]").value = "#FFFFFF"
document.querySelector("[name=combo_color]").style.backgroundColor="rgb(255, 255, 255)"
document.querySelector("[name=combo_color]").style.color="rgb(0, 0, 0)"
OnColorChanged()

}
});


document.getElementById("playareacolor_reset").addEventListener('click', function (){
    var res = confirm("背景カラーをデフォルトに戻します。よろしいですか?");
    if( res == true ) {
document.querySelector("[name=playarea_color]").value = "transparent"
document.querySelector("[name=playarea_color]").style.backgroundColor="transparent"
document.querySelector("[name=playarea_color]").style.color="rgb(0, 0, 0)"

document.querySelector("[name=playarea_radius]").value = 0
document.querySelector("[name=futidori_theme]")[0].selected = true;

document.querySelector("[name=futidori_color]").value = "#FFFFFF"
document.querySelector("[name=futidori_color]").style.backgroundColor="rgb(255, 255, 255)"
document.querySelector("[name=futidori_color]").style.color="rgb(0, 0, 0)"

document.querySelector("[name=futidori_border-width]")[0].selected = true;
OnColorChanged()

}
});


document.getElementById("linecolor_reset").addEventListener('click', function (){
    var res = confirm("ラインカラーをデフォルトに戻します。よろしいですか?");
    if( res == true ) {
document.querySelector("[name=line_color]").value = "#17a2b8";
document.querySelector("[name=line_color]").style.backgroundColor="rgb(23, 162, 184)"
document.querySelector("[name=line_color]").style.color="rgb(255, 255, 255)"

document.querySelector("[name=line_color2]").value = "#ffc107"
document.querySelector("[name=line_color2]").style.backgroundColor="rgb(255, 193, 7)"
document.querySelector("[name=line_color2]").style.color="rgb(0, 0, 0)"

document.querySelector("[name=line_empty_color]").value = "#f5f5f5"
document.querySelector("[name=line_empty_color2]").value = "#f5f5f5"

document.querySelector("[name=line_empty_color]").style.backgroundColor="rgb(245, 245, 245)"
document.querySelector("[name=line_empty_color]").style.color="rgb(0, 0, 0)"

document.querySelector("[name=line_empty_color2]").style.backgroundColor="rgb(245, 245, 245)"
document.querySelector("[name=line_empty_color2]").style.color="rgb(0, 0, 0)"
OnColorChanged()

}
});

document.getElementById("subtextcolor_reset").addEventListener('click', function (){
    var res = confirm("ステータス/コントロール文字色をデフォルトに戻します。よろしいですか?");
    if( res == true ) {
document.querySelector("[name=status_color]").value = "#FFFFFF"
document.querySelector("[name=status_color]").style.backgroundColor="rgb(255, 255, 255)"
document.querySelector("[name=status_color]").style.color="rgb(0, 0, 0)"

document.querySelector("[name=me_color]").value = "#20c997"
document.querySelector("[name=me_color]").style.backgroundColor="rgb(32, 201, 151)"
document.querySelector("[name=me_color]").style.color="rgb(255, 255, 255)"

document.querySelector("[name=control_color]").value = "rgba(255,255,255,.85)"
document.querySelector("[name=control_color]").style.backgroundColor="rgba(255, 255, 255, 0.85)"
document.querySelector("[name=control_color]").style.color="rgb(0, 0, 0)"
OnColorChanged()

}
});



var modal_overlay_html= document.createElement('div');
    modal_overlay_html.setAttribute("id", "modal-overlay");
    modal_overlay_html.setAttribute("style", "display:none;");
document.body.appendChild(modal_overlay_html);


  // おすすめ設定追加
var mask_html = document.createElement('div');
    mask_html.setAttribute("id", "mask");
    mask_html.setAttribute("class", "hidden");

var section_html = document.createElement('section');
    section_html.setAttribute("id", "modal");
    section_html.setAttribute("class", "hidden");
    section_html.innerHTML = '<div id="close" >動画・音楽重視</div><div id="close2" >タイピング重視</div>'
document.getElementsByClassName("share")[0].parentNode.insertBefore(mask_html , document.getElementsByClassName("share")[0].nextElementSibling);
document.getElementsByClassName("share")[0].parentNode.insertBefore(section_html , document.getElementsByClassName("share")[0].nextElementSibling);


window.addEventListener('click', evt => {
if(evt.srcElement.id=='osusume') {
    document.getElementById('modal').classList.remove('hidden');
    document.getElementById('mask').classList.remove('hidden');
}
if(evt.srcElement.id=='mask') {
    document.getElementById('modal').classList.add('hidden');
    document.getElementById('mask').classList.add('hidden');
}
if(evt.srcElement.id=='close') {
    document.getElementById('modal').classList.add('hidden');
    document.getElementById('mask').classList.add('hidden');
document.querySelector("[value=status_mode_not_break]").checked = true;
document.querySelector("[value=mizumasi]").checked = true;
document.querySelector("[value="+CSS.escape(-10)+"]").selected = true;
document.querySelector("[value=play_scroll]").checked = true;
document.querySelector("[value=line_count]").checked = true;
document.querySelector("[value=rank]").checked = true;
document.querySelector("[value=typing_speed]").checked = true;
document.querySelector("[value=escape_counter]").checked = true;
document.querySelector("[value=skip_space]").checked = true;
document.querySelector("[value=miss_on]").checked = true;
document.querySelector("[value=gameover_sound]").checked = true;
document.querySelector("[value=anime_count]").checked = true;
document.querySelector("[value=sub]").checked = true;
document.querySelector("[value=Interlocking_volume]").checked = true;
document.querySelector("[value=skip_guide]").checked = true;
document.querySelector("[value=score]").checked = true;
document.querySelector("[value=miss]").checked = true;
document.querySelector("[value=acc]").checked = true;
document.querySelector("[value=combo_counter]").checked = true;
document.querySelector("[value=type_counter]").checked = true;
document.querySelector("[value=clear_counter]").checked = true;

document.querySelector("[value=gauge]").checked = false;
document.querySelector("[value=not_video]").checked = false;
document.querySelector("[value=word_disable]").checked = false;
document.querySelector("[value=oomoji_shift]").checked = false;
document.querySelector("[value=perfect_mode]").checked = false;
document.querySelector("[value=combo_animation]").checked = false;
document.querySelector("[value=letter_scroll]").checked = false;
document.querySelector("[value=line_hidden]").checked = false;
document.querySelector("[value=type_sound]").checked = false;
document.querySelector("[value=miss_sound]").checked = false;
document.querySelector("[value=miss_sound_top]").checked = false;
document.querySelector("[value=clear_sound]").checked = false;
document.querySelector("[value=combo_break_sound]").checked = false;
document.querySelector("[value=eng_highlight]").checked = false;
document.querySelector("[value=combo_display]").checked = false;

document.querySelector("[name=font_size_kana]").value = 17.5;
document.querySelector("[name=font_size_roma]").value = 17.5;

if(localStorage.getItem('playarea_color')=="rgba(0,0,0,0.5)"){
document.querySelector("[name=playarea_color]").value = "transparent"
document.querySelector("[name=playarea_color]").style.backgroundColor='transparent';
document.querySelector("[name=playarea_color]").style.color='rgb(0, 0, 0)';
}
color_default()
setting_save()
if(is_played){
window.scrollTo({
    top: (document.documentElement.scrollTop+document.getElementById("controlbox").getBoundingClientRect().top+document.getElementById("controlbox").clientHeight-document.documentElement.clientHeight-10),
behavior: "smooth",
});
}


}

if(evt.srcElement.id=='close2') {
    document.getElementById('modal').classList.add('hidden');
    document.getElementById('mask').classList.add('hidden');
document.querySelector("[value=status_mode_new_line]").checked = true;
document.querySelector("[value=gauge]").checked = true;
document.querySelector("[value=center]").checked = true;
document.querySelector("[value=mizumasi]").checked = true;
document.querySelector("[value=next_text_lyric]").checked = true;
document.querySelector("[value=play_scroll]").checked = true;
document.querySelector("[value=type_sound]").checked = true;
document.querySelector("[value=miss_sound]").checked = true;
document.querySelector("[value=clear_sound]").checked = true;
document.querySelector("[value=combo_break_sound]").checked = true;
document.querySelector("[value=line_count]").checked = true;
document.querySelector("[value=rank]").checked = true;
document.querySelector("[value=typing_speed]").checked = true;
document.querySelector("[value=escape_counter]").checked = true;
document.querySelector("[value=skip_space]").checked = true;
document.querySelector("[value=miss_on]").checked = true;
document.querySelector("[value=gameover_sound]").checked = true;
document.querySelector("[value=anime_count]").checked = true;
document.querySelector("[value=sub]").checked = true;
document.querySelector("[value=Interlocking_volume]").checked = true;
document.querySelector("[value=skip_guide]").checked = true;
document.querySelector("[value=score]").checked = true;
document.querySelector("[value=miss]").checked = true;
document.querySelector("[value=acc]").checked = true;
document.querySelector("[value=combo_counter]").checked = true;
document.querySelector("[value=type_counter]").checked = true;
document.querySelector("[value=clear_counter]").checked = true;
document.querySelector("[value="+CSS.escape(55)+"]").selected = true;

document.querySelector("[value=not_video]").checked = false;
document.querySelector("[value=word_disable]").checked = false;
document.querySelector("[value=oomoji_shift]").checked = false;
document.querySelector("[value=perfect_mode]").checked = false;
document.querySelector("[value=combo_animation]").checked = false;
document.querySelector("[value=letter_scroll]").checked = false;
document.querySelector("[value=line_hidden]").checked = false;
document.querySelector("[value=eng_highlight]").checked = false;
document.querySelector("[value=combo_display]").checked = false;

document.querySelector("[name=font_size_kana]").value = 17.5;
document.querySelector("[name=font_size_roma]").value = 17.5;

if(localStorage.getItem('playarea_color')=="transparent"){
document.querySelector("[name=playarea_color]").value = "rgba(0,0,0,0.5)";
document.querySelector("[name=playarea_color]").style.backgroundColor='rgba(0,0,0,0.5)';
document.querySelector("[name=playarea_color]").style.color='rgb(0, 0, 0)';
}
letter_red()
setting_save()


if(is_played){
window.scrollTo({
    top: (document.documentElement.scrollTop+document.getElementById("controlbox").getBoundingClientRect().top+document.getElementById("controlbox").clientHeight-document.documentElement.clientHeight-10),
behavior: "smooth",
});
}

}
});


document.getElementById("mod_setting").addEventListener('change', setting_save);
document.querySelector("[value=type_sound]").addEventListener('change', function(){if(document.querySelector("[value=type_sound]").checked){key_type_play()}});
document.querySelector("[value=miss_sound]").addEventListener('change', function(){if(document.querySelector("[value=miss_sound]").checked){miss_type_play()
document.getElementById("miss_top_checkbox").style.display = "";

}else{
document.getElementById("miss_top_checkbox").style.display = "none";
}
});document.querySelector("[value=clear_sound]").addEventListener('change', function(){if(document.querySelector("[value=clear_sound]").checked){clear_type_play()}});
document.querySelector("[value=combo_break_sound]").addEventListener('change', function(){if(document.querySelector("[value=combo_break_sound]").checked){combo_break.play()}});
document.querySelector("[value=gameover_sound]").addEventListener('change', function(){if(document.querySelector("[value=gameover_sound]").checked){gameover_sound.play()}});
document.querySelector("[value=status_mode_not_break]").addEventListener('change',scroll_change)
document.querySelector("[value=status_mode_new_line]").addEventListener('change',scroll_change)
document.querySelector("[value=not_video]").addEventListener('change',scroll_change)
document.querySelector("[name=scroll_adjustment1]").addEventListener('change',scroll_change)


document.getElementById("initial_diff_reset").addEventListener('click', function (){
initial_diff=0
document.getElementById("initial_diff").textContent = initial_diff.toFixed(2);
localStorage.setItem('diff_storage', Number(initial_diff))
});


document.getElementById("initial_diff_minus").addEventListener('click', function (){
initial_diff=Number(Number(localStorage.getItem('diff_storage')))

if(initial_diff != -4){
if(!event.shiftKey){
initial_diff=Number((initial_diff-0.01).toFixed(2))
}else{
initial_diff=Number((initial_diff-0.1).toFixed(2))
}
}else if(initial_diff == -4){
initial_diff=-4
}
document.getElementById("initial_diff").textContent = initial_diff.toFixed(2);
localStorage.setItem('diff_storage', Number(initial_diff))
player.difftime = Number(localStorage.getItem('diff_storage'))
});

document.getElementById("initial_diff_plus").addEventListener('click', function (){
initial_diff=Number(Number(localStorage.getItem('diff_storage')))

if(initial_diff != 4){
if(!event.shiftKey){
initial_diff=Number((initial_diff+0.01).toFixed(2))
}else{
initial_diff=Number((initial_diff+0.1).toFixed(2))
}
}else if(initial_diff == 4){
initial_diff=4
}
document.getElementById("initial_diff").textContent = initial_diff.toFixed(2);
localStorage.setItem('diff_storage', Number(initial_diff))
player.difftime = Number(localStorage.getItem('diff_storage'))

});

document.getElementById("initial_speed_reset").addEventListener('click', function (){
initial_speed1=1;initial_speed2=1;initial_speed3=1;initial_speed4=1;initial_speed5=1;
document.getElementById("initial_speed1").textContent="1.00";
document.getElementById("initial_speed2").textContent="1.00";
document.getElementById("initial_speed3").textContent="1.00";
document.getElementById("initial_speed4").textContent="1.00";
document.getElementById("initial_speed5").textContent="1.00";
initial_speed=[initial_speed1,initial_speed2,initial_speed3,initial_speed4,initial_speed5]
localStorage.setItem('initial_speed',JSON.stringify(initial_speed))
});

document.getElementById("initial_speed1_down").addEventListener('click', function (){
if(initial_speed1 != 0.25){
initial_speed1=(initial_speed1-0.25)
}else if(initial_speed1 == 0.25){
initial_speed1=0.25
}
document.getElementById("initial_speed1").textContent = initial_speed1.toFixed(2);
initial_speed=[initial_speed1,initial_speed2,initial_speed3,initial_speed4,initial_speed5]
localStorage.setItem('initial_speed',JSON.stringify(initial_speed))
});

document.getElementById("initial_speed1_up").addEventListener('click', function (){
if(initial_speed1 != 2){
initial_speed1=(initial_speed1+0.25)
}else if(initial_speed1 == 2){
initial_speed1=2.00
}
document.getElementById("initial_speed1").textContent = initial_speed1.toFixed(2);
initial_speed=[initial_speed1,initial_speed2,initial_speed3,initial_speed4,initial_speed5]
localStorage.setItem('initial_speed',JSON.stringify(initial_speed))
});

document.getElementById("initial_speed2_down").addEventListener('click', function (){
if(initial_speed2 != 0.25){
initial_speed2=(initial_speed2-0.25)
}else if(initial_speed2 == 0.25){
initial_speed2=0.25
}
document.getElementById("initial_speed2").textContent = initial_speed2.toFixed(2);
initial_speed=[initial_speed1,initial_speed2,initial_speed3,initial_speed4,initial_speed5]
localStorage.setItem('initial_speed',JSON.stringify(initial_speed))
});

document.getElementById("initial_speed2_up").addEventListener('click', function (){
if(initial_speed2 != 2){
initial_speed2=(initial_speed2+0.25)
}else if(initial_speed2 == 2){
initial_speed2=2
}
document.getElementById("initial_speed2").textContent = initial_speed2.toFixed(2);
initial_speed=[initial_speed1,initial_speed2,initial_speed3,initial_speed4,initial_speed5]
localStorage.setItem('initial_speed',JSON.stringify(initial_speed))
});


document.getElementById("initial_speed3_down").addEventListener('click', function (){
if(initial_speed3 != 0.25){
initial_speed3=(initial_speed3-0.25)
}else if(initial_speed3 == 0.25){
initial_speed3=0.25
}
document.getElementById("initial_speed3").textContent = initial_speed3.toFixed(2);
initial_speed=[initial_speed1,initial_speed2,initial_speed3,initial_speed4,initial_speed5]
localStorage.setItem('initial_speed',JSON.stringify(initial_speed))
});


document.getElementById("initial_speed3_up").addEventListener('click', function (){
if(initial_speed3 != 2){
initial_speed3=(initial_speed3+0.25)
}else if(initial_speed3 == 2){
initial_speed3=2
}
document.getElementById("initial_speed3").textContent = initial_speed3.toFixed(2);
initial_speed=[initial_speed1,initial_speed2,initial_speed3,initial_speed4,initial_speed5]
localStorage.setItem('initial_speed',JSON.stringify(initial_speed))
});


document.getElementById("initial_speed4_down").addEventListener('click', function (){
if(initial_speed4 != 0.25){
initial_speed4=(initial_speed4-0.25)
}else if(initial_speed4 == 0.25){
initial_speed4=0.25
}
document.getElementById("initial_speed4").textContent = initial_speed4.toFixed(2);
initial_speed=[initial_speed1,initial_speed2,initial_speed3,initial_speed4,initial_speed5]
localStorage.setItem('initial_speed',JSON.stringify(initial_speed))
});


document.getElementById("initial_speed4_up").addEventListener('click', function (){
if(initial_speed4 != 2){
initial_speed4=(initial_speed4+0.25)
}else if(initial_speed4 == 2){
initial_speed4=2
}
document.getElementById("initial_speed4").textContent = initial_speed4.toFixed(2);
initial_speed=[initial_speed1,initial_speed2,initial_speed3,initial_speed4,initial_speed5]
localStorage.setItem('initial_speed',JSON.stringify(initial_speed))
});


document.getElementById("initial_speed5_down").addEventListener('click', function (){
if(initial_speed5 != 0.25){
initial_speed5=(initial_speed5-0.25)
}else if(initial_speed5 == 0.25){
initial_speed5=0.25
}
document.getElementById("initial_speed5").textContent = initial_speed5.toFixed(2);
initial_speed=[initial_speed1,initial_speed2,initial_speed3,initial_speed4,initial_speed5]
localStorage.setItem('initial_speed',JSON.stringify(initial_speed))
});


document.getElementById("initial_speed5_up").addEventListener('click', function (){
if(initial_speed5 != 2){
initial_speed5=(initial_speed5+0.25)
}else if(initial_speed5 == 2){initial_speed5=2}
document.getElementById("initial_speed5").textContent = initial_speed5.toFixed(2);
initial_speed=[initial_speed1,initial_speed2,initial_speed3,initial_speed4,initial_speed5]
localStorage.setItem('initial_speed',JSON.stringify(initial_speed))
});

}

function color_default(){
document.querySelector("[name=first_color]").value = "#FFFFFF"
document.querySelector("[name=lyric_color]").value = "#FFFFFF"
document.querySelector("[name=word_color]").value = "#FFFFFF"

document.querySelector("[name=first_color]").style.backgroundColor="rgb(255, 255, 255)"
document.querySelector("[name=first_color]").style.color="rgb(0, 0, 0)"
document.querySelector("[name=lyric_color]").style.backgroundColor="rgb(255, 255, 255)"
document.querySelector("[name=lyric_color]").style.color="rgb(0, 0, 0)"
document.querySelector("[name=word_color]").style.backgroundColor="rgb(255, 255, 255)"
document.querySelector("[name=word_color]").style.color="rgb(0, 0, 0)"

document.querySelector("[name=correctword_color]").value = "#0099CC"
document.querySelector("[name=correctword_color]").style.backgroundColor="rgb(0, 153, 204)"
document.querySelector("[name=correctword_color]").style.color="rgb(255, 255, 255)"

document.querySelector("[name=lineclear_color]").value = "#1eff52"
document.querySelector("[name=lineclear_color]").style.backgroundColor="rgb(30, 255, 82)"
document.querySelector("[name=lineclear_color]").style.color="rgb(255, 255, 255)"

document.querySelector("[name=next_lyrics_color]").value = "rgba(255,255,255,.7)"
document.querySelector("[name=next_lyrics_color]").style.backgroundColor="rgba(255, 255, 255, 0.7)"
document.querySelector("[name=next_lyrics_color]").style.color="rgb(0, 0, 0)"
OnColorChanged()

}
function letter_red(){
document.querySelector("[name=first_color]").value = "#FF0000"
document.querySelector("[name=first_color]").style.backgroundColor="rgb(255, 0, 0)"
document.querySelector("[name=first_color]").style.color="rgb(255, 255, 255)"

document.querySelector("[name=lyric_color]").value = "#FFFFFF"
document.querySelector("[name=word_color]").value = "#FFFFFF"
document.querySelector("[name=lyric_color]").style.backgroundColor="rgb(255, 255, 255)"
document.querySelector("[name=lyric_color]").style.color="rgb(0, 0, 0)"
document.querySelector("[name=word_color]").style.backgroundColor="rgb(255, 255, 255)"
document.querySelector("[name=word_color]").style.color="rgb(0, 0, 0)"

document.querySelector("[name=correctword_color]").value = "#919395"
document.querySelector("[name=correctword_color]").style.backgroundColor="rgb(145, 147, 149)"
document.querySelector("[name=correctword_color]").style.color="rgb(255, 255, 255)"

document.querySelector("[name=lineclear_color]").value = "#919395"
document.querySelector("[name=lineclear_color]").style.backgroundColor="rgb(145, 147, 149)"
document.querySelector("[name=lineclear_color]").style.color="rgb(255, 255, 255)"

document.querySelector("[name=next_lyrics_color]").value = "rgba(255,255,255,.7)"
document.querySelector("[name=next_lyrics_color]").style.backgroundColor="rgba(255, 255, 255, 0.7)"
document.querySelector("[name=next_lyrics_color]").style.color="rgb(0, 0, 0)"
OnColorChanged()

}

function add_css(){
var stylesheet = document.styleSheets.item(0)

    stylesheet.insertRule("#kashi_roma:after,#kashi_sub:after,#skip_guide:after,#kashi_next:after,#next_kpm:after{content:'\u200b';}", 24);
    stylesheet.insertRule(".fa-cog:hover{transform:rotate(90deg);}", 26);
    stylesheet.insertRule('.gothicfont{font-family: Segoe UI , "Yu Gothic","YuGothic"!important;}',27);
    stylesheet.insertRule('.ui-dialog-buttonset button:last-of-type{opacity:0.5;zoom:70%;}',27);

    stylesheet.insertRule('#kashi_area{cursor:none!important;user-select: none !important;-ms-user-select: none !important;-moz-user-select: none !important;-webkit-user-select: none !important;}',29);
    stylesheet.insertRule("[onclick='submit_score()']:after{content:'Enterキーでランキング送信';}", 30);
    stylesheet.insertRule(".letter_space{letter-spacing: 0.7px;}", 31);
    stylesheet.insertRule(".kashi_hidden{visibility:hidden;}", 34);
    stylesheet.insertRule(".letter_scroll{white-space: nowrap;position:relative;height:25.591px;overflow:hidden;}", 36);
  stylesheet.insertRule(".jp_word{word-break:break-all;}", 37);
  stylesheet.insertRule(".eng_word{word-wrap: break-word;overflow-wrap:break-word;}", 37);

    stylesheet.insertRule(".progress{margin-bottom: 0!important;}", 38);
    stylesheet.insertRule(".sub_margin{margin-top: 0.5rem!important;}", 39);
    stylesheet.insertRule(".next_hidden{visibility: hidden!important;white-space: nowrap;overflow:hidden;}", 40);
    stylesheet.insertRule("#mod_setting label,.col-6 label,.status .nav-fill{cursor: pointer;}", 41);
    stylesheet.insertRule("#mod_setting label{margin-right: 5px;}", 42);

    stylesheet.insertRule('#kashi_next{margin-top:0px!important;}',46);

    stylesheet.insertRule('#modal-open:hover{  cursor: pointer;text-decoration : underline;}',47);
    stylesheet.insertRule('.underline{text-decoration : underline;}',47);

    stylesheet.insertRule('#controlbox .col-6{padding-right: 0!important;}',48);
    stylesheet.insertRule('#controlbox{margin-left:0px!important;    padding-top: 6px;}',49);
    stylesheet.insertRule('#status{font-size:1.4rem;white-space: nowrap;letter-spacing: 0.8px;filter: blur(0);line-height:31px!important;margin-bottom: 8px;margin-top: 2px;}',50);
    stylesheet.insertRule('.progress2{margin-bottom: 0.5vw; -webkit-box-shadow: inset 0 0.1vw 0.2vw rgba(0,0,0,.1);box-shadow: inset 0 0.1vw 0.2vw rgba(0,0,0,.1);border-radius: 0;display: flex;font-size: .75rem;line-height: 3px;text-align: center;background-color: rgba(255,255,255,.1);}',51);
    stylesheet.insertRule('#gauge1{position:relative;top:5px;border-top:thin solid;border-bottom:thin solid;border-left:thin solid;height: 5px;}',52);
    stylesheet.insertRule('#gauge2{height:13px!important;border-top:thin #FFEB3B solid;border-right:thin #FFEB3B solid;border-bottom:thin #FFEB3B solid;}',53);
    stylesheet.insertRule('.col-4{padding-top:4px;}',54);
    stylesheet.insertRule('div#gauge {width: 75%;padding-left: 10px;}',55);
    stylesheet.insertRule('.combo_center{width:100%;}',57);
    stylesheet.insertRule('#playBotton1 a:hover,#playBotton2 a:hover,#playBotton4 a:hover,#playBotton5 a:hover,.under_line{text-decoration: underline;}',61);
    stylesheet.insertRule('.no_select{text-decoration: none!important;cursor: context-menu!important;}',62);
    stylesheet.insertRule('.uppercase{text-transform:uppercase;}',63);
//    stylesheet.insertRule('#kashi_roma .first_letter{     background-image: url(data:image/gif;base64,R0lGODlhAQAoAPABAERmZv///yH5BAg1AAAAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAAQAoAAACBYSPqctYACH5BAg1AAAALAAAAAABACgAgP///////wIFhI+py1gAOw==);   background-repeat: repeat-y;}',63);


    stylesheet.insertRule('.status_text:before {content: "";position: absolute;bottom: 3.89rem;display: inline-block;width: 62px;height: 1px;background-color: white;}',64);
    stylesheet.insertRule('.status_text2:before {content: "";position: absolute;bottom: 0.66rem;display: inline-block;width: 62px;height: 1px;background-color: white;}',65);
    stylesheet.insertRule('#time_settings{float: left!important;}',66);
    stylesheet.insertRule('.score_text:before {content: "";position: absolute;bottom: 3.89rem;display: inline-block;width: 67px;height: 1px;background-color: white;}',68);
    stylesheet.insertRule('.score_text2:before {content: "";position: absolute;bottom: 0.66rem;display:inline-block;left:40.4px;width: 68px;height: 1px;background-color: white;}',69);
    stylesheet.insertRule('.status_label{position:relative;top: 2px;text-transform:capitalize;}',70);

    stylesheet.insertRule('.line_text:before {content: "";position: absolute;bottom: 3.89rem;display: inline-block;width: 47px;height: 1px;background-color: white;}',72);
    stylesheet.insertRule('.line_text2:before {content: "";position: absolute;bottom: 0.66rem;display:inline-block;width: 47px;height: 1px;background-color: white;}',73);
    stylesheet.insertRule('.status_text_result:before {content: "";position: absolute;bottom: 3.89rem;display: inline-block;width: 79px;height: 1px;background-color: white;}',72);
    stylesheet.insertRule('.status_text_result2:before {content: "";position: absolute;bottom: 0.66rem;display:inline-block;width: 106px;height: 1px;background-color: white;}',73);
if(window.navigator.userAgent.indexOf('Firefox') != -1) {
    stylesheet.insertRule("progress{width:100%;height:5px!important;;appearance:none;margin-top:1vw;}", 74);
}else{
    stylesheet.insertRule("progress{width:100%;height:3px!important;-webkit-appearance: scale-horizontal;appearance: scale-horizontal;margin-top:1vw;}", 74);
}
}






var line_color_styles_html = document.createElement('style');
    line_color_styles_html.setAttribute("id", "line_color_styles");
var status_setting_html = document.createElement('style');
    status_setting_html.setAttribute("id", "status_setting");
//localstorageを読み込む
(function read_localstorage(){
//localstorageからカラーコード&設定数値を反映
if(localStorage.getItem('miss_limit')){document.querySelector("[name=miss_limit]").value = localStorage.getItem('miss_limit')}
if(localStorage.getItem('font_size_kana')){document.querySelector("[name=font_size_kana]").value = localStorage.getItem('font_size_kana')}
if(localStorage.getItem('font_size_roma')){document.querySelector("[name=font_size_roma]").value = localStorage.getItem('font_size_roma')}
if(localStorage.getItem('ef_volume_type')){document.querySelector("[name=effect_volume_type]").value = localStorage.getItem('ef_volume_type')}
if(localStorage.getItem('ef_volume_miss')){document.querySelector("[name=effect_volume_miss]").value = localStorage.getItem('ef_volume_miss')}
if(localStorage.getItem('ef_volume_clear')){document.querySelector("[name=effect_volume_clear]").value = localStorage.getItem('ef_volume_clear')}
if(localStorage.getItem('letter_scroll_kana')){document.querySelector("[name=letter_scroll_kana]").value = localStorage.getItem('letter_scroll_kana')}
if(localStorage.getItem('letter_scroll_roma')){document.querySelector("[name=letter_scroll_roma]").value = localStorage.getItem('letter_scroll_roma')}
if(localStorage.getItem('effect_volume_gameover')){document.querySelector("[name=effect_volume_gameover]").value = localStorage.getItem('effect_volume_gameover')}
if(localStorage.getItem('ef_volume_combo_break')){document.querySelector("[name=effect_volume_combo_break]").value = localStorage.getItem('ef_volume_combo_break')}
if(localStorage.getItem('line_color')){document.querySelector("[name=line_color]").value = localStorage.getItem('line_color')}
if(localStorage.getItem('line_color2')){document.querySelector("[name=line_color2]").value = localStorage.getItem('line_color2')}
if(localStorage.getItem('line_empty_color')){document.querySelector("[name=line_empty_color]").value = localStorage.getItem('line_empty_color')}
if(localStorage.getItem('line_empty_color')){document.querySelector("[name=line_empty_color2]").value = localStorage.getItem('line_empty_color2')}
if(localStorage.getItem('status_color')){document.querySelector("[name=status_color]").value = localStorage.getItem('status_color')}
if(localStorage.getItem('me_color')){document.querySelector("[name=me_color]").value = localStorage.getItem('me_color')}
if(localStorage.getItem('line_empty_color')){document.querySelector("[name=control_color]").value = localStorage.getItem('control_color')}
if(localStorage.getItem('miss_color')){document.querySelector("[name=miss_color]").value = localStorage.getItem('miss_color')}
if(localStorage.getItem('countdown_color')){document.querySelector("[name=countdown_color]").value = localStorage.getItem('countdown_color')}
if(localStorage.getItem('skipguide_color')){document.querySelector("[name=skipguide_color]").value = localStorage.getItem('skipguide_color')}
if(localStorage.getItem('combo_color')){document.querySelector("[name=combo_color]").value = localStorage.getItem('combo_color')}
if(localStorage.getItem('first_color1')){document.querySelector("[name=first_color]").value = localStorage.getItem('first_color1')}
if(localStorage.getItem('playarea_color')){document.querySelector("[name=playarea_color]").value = localStorage.getItem('playarea_color')}
if(localStorage.getItem('playarea_radius')){document.querySelector("[name=playarea_radius]").value = localStorage.getItem('playarea_radius')}
if(localStorage.getItem('futidori_color')){document.querySelector("[name=futidori_color]").value = localStorage.getItem('futidori_color')}
if(localStorage.getItem('correctword_color')){document.querySelector("[name=correctword_color]").value = localStorage.getItem('correctword_color')}
if(localStorage.getItem('word_color')){document.querySelector("[name=word_color]").value = localStorage.getItem('word_color')}
if(localStorage.getItem('lineclear_color')){document.querySelector("[name=lineclear_color]").value = localStorage.getItem('lineclear_color')}
if(localStorage.getItem('lyric_color')){document.querySelector("[name=lyric_color]").value = localStorage.getItem('lyric_color')}
if(localStorage.getItem('next_lyrics_color')){document.querySelector("[name=next_lyrics_color]").value = localStorage.getItem('next_lyrics_color')}


//時間オフセット
if(!localStorage.getItem('diff_storage')){
    localStorage.setItem('diff_storage',0)
}
initial_diff=Number(localStorage.getItem('diff_storage'));
document.getElementById("time_diff").textContent = initial_diff.toFixed(2);
document.getElementById("initial_diff").textContent = initial_diff.toFixed(2);



//ここからチェックボックス保存(サーバーで保存される機能実装までの仮実装)
document.querySelector(".status .nav").children[1].classList.add('under_line');
if(localStorage.getItem('sub') == "false"){document.querySelector("[value=sub]").checked = false;}
if(localStorage.getItem('eng_highlight') == "true"){document.querySelector("[value=eng_highlight]").checked = true;}
if(localStorage.getItem('letter_scroll') == "true"){document.querySelector("[value=letter_scroll]").checked = true;}
if(localStorage.getItem('line_hidden') == "true"){document.querySelector("[value=line_hidden]").checked = true;}
if(localStorage.getItem('oomoji_shift') == "true"){document.querySelector("[value=oomoji_shift]").checked = true;}
if(localStorage.getItem('type_sound') == "true"){document.querySelector("[value=type_sound]").checked = true;}
if(localStorage.getItem('miss_sound') == "true"){document.querySelector("[value=miss_sound]").checked = true;
document.getElementById("miss_top_checkbox").style.display = "";
}
if(localStorage.getItem('miss_sound_top') == "true"){document.querySelector("[value=miss_sound_top]").checked = true;}
if(localStorage.getItem('clear_sound') == "true"){document.querySelector("[value=clear_sound]").checked = true;}
if(localStorage.getItem('combo_break_sound') == "true"){document.querySelector("[value=combo_break_sound]").checked = true;}
if(localStorage.getItem('gameover_sound') == "false"){document.querySelector("[value=gameover_sound]").checked = false;}
if(localStorage.getItem('Interlocking_volume') == "false"){document.querySelector("[value=Interlocking_volume]").checked = false;}
if(localStorage.getItem('mizumasi') == "true"){document.querySelector("[value=mizumasi]").checked = true;}
if(localStorage.getItem('word_disable') == "true"){document.querySelector("[value=word_disable]").checked = true;}
if(localStorage.getItem('kigou_disable') == "true"){document.querySelector("[value=kigou_disable]").checked = true;}
if(localStorage.getItem('space_disable') == "true"){document.querySelector("[value=space_disable]").checked = true;}
if(localStorage.getItem('miss_on') == "false"){document.querySelector("[value=miss_on]").checked = false;}
if(localStorage.getItem('anime_count') == "false"){document.querySelector("[value=anime_count]").checked = false;}
if(localStorage.getItem('count_animation') == "false"){document.querySelector("[value=count_animation]").checked = false;}
if(localStorage.getItem('skip_guide') == "false"){document.querySelector("[value=skip_guide]").checked = false;}
if(localStorage.getItem('skip_key') == "true"){document.querySelector("[value=skip_enter]").checked = true;}
if(localStorage.getItem('word_result') == "false"){document.querySelector("[value=word_result_real]").checked = true;}
if(localStorage.getItem('perfect_mode') == "true"){document.querySelector("[value=perfect_mode]").checked = true;}
if(localStorage.getItem('miss_limit_mode') == "true"){document.querySelector("[value=keep_corrent]").checked = true;}
if(localStorage.getItem('gauge') == "true"){document.querySelector("[value=gauge]").checked = true;}
if(localStorage.getItem('combo_display') == "true"){document.querySelector("[value=combo_display]").checked = true;}
if(localStorage.getItem('combo_animation') == "true"){document.querySelector("[value=combo_animation]").checked = true;}
if(localStorage.getItem('next_text') == "true"){document.querySelector("[value=next_text_reading]").checked = true;}
if(localStorage.getItem('play_scroll1') == "true"){document.querySelector("[value=play_scroll]").checked = true;}
if(localStorage.getItem('status_mode') == "true"){document.querySelector("[value=status_mode_new_line]").checked = true;}
if(localStorage.getItem('not_video') == "true"){document.querySelector("[value=not_video]").checked = true;}
if(localStorage.getItem('mode_select1') == ("kanamode_type"||"kanamode_mac_type") && document.querySelectorAll("[name=mode_select]")[2] == null || !localStorage.getItem('mode_select1')){
document.querySelector("[value='kana_type']").checked = true;
}else{
document.querySelector("[value="+localStorage.getItem('mode_select1')+"]").checked = true;
}
if(localStorage.getItem('futidori_theme')){document.querySelector("[value="+localStorage.getItem('futidori_theme')+"]").selected = true;}
if(localStorage.getItem('futidori_border-width')){document.querySelector("[value="+localStorage.getItem('futidori_border-width')+"]").selected = true;}
if(localStorage.getItem('scroll_adjustment1')){document.querySelector("[value="+CSS.escape(localStorage.getItem('scroll_adjustment1'))+"]").selected = true;}

if(!localStorage.getItem('score1')){
    localStorage.setItem('score1',"display:block;")
}else if(localStorage.getItem('score1') == "display:none;" || localStorage.getItem('score1') == "visibility:hidden;display:block;"){
document.querySelector("[value=score]").checked = false;
}if(!localStorage.getItem('miss1')){
    localStorage.setItem('miss1',"display:display:block;")
}else if(localStorage.getItem('miss1') == "display:none;" || localStorage.getItem('miss1') == "visibility:hidden;display:block;"){
document.querySelector("[value=miss]").checked = false;
}if(!localStorage.getItem('acc1')){
    localStorage.setItem('acc1',".acc{display:block;line-height:0;margin-bottom:15.5px;font-size:95%;font-weight:normal;}")
}else if(localStorage.getItem('acc1') == ".acc{display:none;}" || localStorage.getItem('acc1') == ".acc{visibility:hidden;display:block;}"){
document.querySelector("[value=acc]").checked = false;
}if(!localStorage.getItem('combo_counter1')){
    localStorage.setItem('combo_counter1',"display:block;")
}else if(localStorage.getItem('combo_counter1') == "display:none;" || localStorage.getItem('combo_counter1') == "visibility:hidden;display:block;"){
document.querySelector("[value=combo_counter]").checked = false;
}if(!localStorage.getItem('type_counter1')){
    localStorage.setItem('type_counter1',"display:inline-block;")
}else if(localStorage.getItem('type_counter1') == "display:none;" || localStorage.getItem('type_counter1') == "visibility:hidden;display:block;"){
document.querySelector("[value=type_counter]").checked = false;
}if(!localStorage.getItem('clear_counter1')){
    localStorage.setItem('clear_counter1',"display:inline-block;")
}else if(localStorage.getItem('clear_counter1') == "display:none;" || localStorage.getItem('clear_counter1') == "visibility:hidden;display:block;"){
document.querySelector("[value=clear_counter]").checked = false;
}if(!localStorage.getItem('escape_counter1')){
    localStorage.setItem('escape_counter1',"display:inline;")
}else if(localStorage.getItem('escape_counter1') == "display:none;" || localStorage.getItem('escape_counter1') == "visibility:hidden;display:block;"){
document.querySelector("[value=escape_counter]").checked = false;
}if(!localStorage.getItem('line_count1')){
    localStorage.setItem('line_count1',"display:inline;")
}else if(localStorage.getItem('line_count1') == "display:none;" || localStorage.getItem('line_count1') == "visibility:hidden;display:block;"){
document.querySelector("[value=line_count]").checked = false;
}if(!localStorage.getItem('rank')){
    localStorage.setItem('rank',"display:inline-block;")
}else if(localStorage.getItem('rank') == "display:none;" || localStorage.getItem('rank') == "visibility:hidden;"){
document.querySelector("[value=rank]").checked = false;
}if(!localStorage.getItem('typing_speed')){
    localStorage.setItem('typing_speed',"display:inline;")
}else if(localStorage.getItem('typing_speed') == "display:none;" || localStorage.getItem('typing_speed') == "visibility:hidden;display:block;"){
document.querySelector("[value=typing_speed]").checked = false;
}

//チェックボックス保存ここまで(サーバー保存の機能ができ次第削除)


//CSS設定を反映
document.getElementById("controlbox").style.backgroundColor=document.querySelector("[name=playarea_color]").value;
document.getElementById("controlbox").style.borderRadius=document.querySelector("[name=playarea_radius]").value+"px";
document.getElementById("controlbox").style.border=document.querySelector("[name=futidori_theme]").value;
document.getElementById("controlbox").style.borderColor=document.querySelector("[name=futidori_color]").value;
document.getElementById("controlbox").style.borderWidth=document.querySelector("[name=futidori_border-width]").value;
document.getElementById("controlbox").style.paddingBottom="6px";

document.getElementById("esckey").style.color=document.querySelector("[name=status_color]").value;
  for(let i=0;i<document.getElementsByClassName("playButton").length;i++){
    document.getElementsByClassName("playButton")[i].style.color = document.querySelector("[name=status_color]").value;
  }


document.head.appendChild(line_color_styles_html);
document.head.appendChild(status_setting_html);
add_style_tag()

//かなモードをラジオボタンで選択時、ローマ字の練習モードをクリック
document.querySelector("#playBotton1 a").addEventListener('click', function(){kana_mode = false});
document.querySelector("#playBotton2 a").addEventListener('click', function(){kana_mode = false});
document.querySelectorAll("[name=mode_select]")[0].addEventListener('change', setting_save);
document.querySelectorAll("[name=mode_select]")[1].addEventListener('change', setting_save);
if(document.querySelectorAll("[name=mode_select]")[2] != null){
document.querySelectorAll("[name=mode_select]")[2].addEventListener('change', setting_save);
document.querySelectorAll("[name=mode_select]")[3].addEventListener('change', setting_save);
}
document.querySelector(".col-4 .nav").addEventListener('click', function (){
if(document.querySelector("#ranking").style.display == 'block'){
document.querySelector(".status .nav").children[0].classList.remove('under_line');
document.querySelector(".status .nav").children[1].classList.add('under_line');
}else if(document.querySelector("#status").style.display == 'block'){
document.querySelector(".status .nav").children[0].classList.add('under_line');
document.querySelector(".status .nav").children[1].classList.remove('under_line');
}});

load_sound()
checkbox_effect()
}());




function add_style_tag(){
if(window.navigator.userAgent.indexOf('Firefox') != -1) {
    line_color_styles_html.innerHTML=`#bar_input_base::-moz-progress-bar {
    background-color:`+document.querySelector("[name=line_color]").value+`!important;
}
#bar_input_base {
    background-color:`+document.querySelector("[name=line_empty_color]").value+`!important;
}
#bar_base::-moz-progress-bar {
    background-color:`+document.querySelector("[name=line_color2]").value+`!important;
}
#bar_base {
    background-color:`+document.querySelector("[name=line_empty_color2]").value+`!important;
}
#controlbox .text-teal {
    color:`+document.querySelector("[name=me_color]").value+`!important;
}

#controlbox .col-4,
#controlbox .col-4 a,
#controlbox .col-4 .h4,
#line_remaining_time,
#total_time{
    color:`+document.querySelector("[name=status_color]").value+`!important;}

#controlbox .control {
    color:`+document.querySelector("[name=control_color]").value+`!important;}`;
}else{
    line_color_styles_html.innerHTML=`#bar_input_base::-webkit-progress-value{
    background-color:`+document.querySelector("[name=line_color]").value+`!important;
}
#bar_input_base[value]::-webkit-progress-bar {
    background-color:`+document.querySelector("[name=line_empty_color]").value+`!important;
}

#bar_base::-webkit-progress-value {
    background-color:`+document.querySelector("[name=line_color2]").value+`!important;
}
#bar_base[value]::-webkit-progress-bar{
    background-color:`+document.querySelector("[name=line_empty_color2]").value+`!important;
}
#controlbox .text-teal {
    color:`+document.querySelector("[name=me_color]").value+`!important;
}

#controlbox .col-4,
#controlbox .col-4 a,
#controlbox .col-4 .h4,
#line_remaining_time,
#total_time{
    color:`+document.querySelector("[name=status_color]").value+`!important;}

#controlbox .control {
    color:`+document.querySelector("[name=control_color]").value+`!important;}`;
}


    status_setting_html.innerHTML = `.score {
`+localStorage.getItem('score1')+`
}
.miss {
`+localStorage.getItem('miss1')+`
}

`+localStorage.getItem('acc1')+`

.combo_counter {
`+localStorage.getItem('combo_counter1')+`
}

.type_counter {
`+localStorage.getItem('type_counter1')+`
}
.clear_counter {
`+localStorage.getItem('clear_counter1')+`
}
.escape_counter {
`+localStorage.getItem('escape_counter1')+`
}
.line_count {
`+localStorage.getItem('line_count1')+`
}
.rank {
`+localStorage.getItem('rank')+`
}
.typing_speed {
`+localStorage.getItem('typing_speed')+`
}`;


var setting_css =document.createElement('style')
setting_css.innerHTML=`.combo_animated {
	animation-duration: 0.6s;
	animation-fill-mode: both;
}


@keyframes combo_anime {
	0% {
		transform:scale(1.1,1.2);
	} 2% {
		transform:scale(1.1,1.3);
	} 9% {
		transform:scale(1,1);
	}
}

#combo_anime {
	animation-name: combo_anime;
}

.count_animated {
	-webkit-animation-duration: 1s;
	animation-duration: 1s;
	-webkit-animation-fill-mode: both;
	animation-fill-mode: both;
}


@keyframes countdown_animation {
	from {
		opacity: 1;
	} to {
		opacity: 0.0;
	} 10% {
		opacity: 0.9;
	} 20% {
		opacity: 0.8;
	} 30% {
		opacity: 0.7;
	} 40% {
		opacity: 0.6;
	} 50% {
 		opacity: 0.5;
	} 60% {
		opacity: 0.4;
	} 70% {
		opacity: 0.3;
	} 80% {
		opacity: 0.2;
	} 90% {

		opacity: 0.1;
	}
}
.complete_animated {
	-webkit-animation-duration: 0.7s;
	animation-duration: 0.7s;
	-webkit-animation-fill-mode: both;
	animation-fill-mode: both;
}


.countdown_animation {
	-webkit-animation-name: countdown_animation;
	animation-name: countdown_animation;
	-webkit-transform-origin: center center;
	transform-origin: center center;
}

/*タブのスタイル*/
.tab_item {
  width: calc(100%/4);
  height: 30px;
  line-height: 30px;

  font-size: 16px;
  text-align: center;
  color: #565656;
  display: block;
  float: left;
  text-align: center;
  transition: all 0.2s ease;
margin:0px!important;
    border-left: 1px solid #fff;
    border-top: 1px solid #fff;

border-bottom:2px solid #aaa;

}
.colorChooser {

    top: -130px;
zoom:80%;
}
.tab_item:hover{
    border-left: 1px solid #ffcd05!important;
    border-top: 1px solid #ffcd05!important;

  color: #ffcd05!important;
}
[for="etc"]{
    border-right: 1px solid #fff;
}
[for="etc"]:hover{
    border-right: 1px solid #ffcd05!important;

}
[for="all"]:hover~[for="design"],
[for="design"]:hover~[for="playcolor"],
[for="playcolor"]:hover~[for="etc"],
[for="etc"]:hover~.solid
{
    border-left: 1px solid #ffcd05!important;

}
.tab_content_description{
border-bottom:1px solid #fff;
border-left:1px solid #fff;
border-right:1px solid #fff;
}
.tab_content_description h6
{
margin-left: 10px;
}
.tab_content_description label {
margin-left: 10px;
}
.tab_content_description label input {
margin-right: 5px;
margin-left: 5px;
}
form #mod_setting p {
    margin-bottom: 0;
}
/*ラジオボタンを全て消す*/
input[name="tab_item"],input[name="input_page"],input[name="details"] {
  display: none;
}

/*タブ切り替えの中身のスタイル*/
.tab_content,
.page_content,
.details_content {
  display: none;
  clear: both;

}

.tab_content h6{
margin-bottom:0;
padding-top: 10px;
margin-right: 10px;
}
.input_page{
margin-bottom:2px;
padding-top: 7.5px;
margin-left: 0px!important;

}.input_page:hover{
text-decoration: underline;

}.tab_content h6:nth-child(n+5){
border-top-style: inset;
}

/*選択されているタブのコンテンツのみを表示*/
#all:checked ~ #all_content,
#design:checked ~ #design_content,
#playcolor:checked ~ #playcolor_content,
#etc:checked ~ #etc_content,
#page1:checked ~ #page1_content,
#page2:checked ~ #page2_content,
#details:checked ~ #details_content {
  display: block!important;
}

/*選択されているタブのスタイルを変える*/
input:checked + .tab_item {
border-bottom:hidden;

  color: #fff!important;
}
input:checked + .input_page,#details:checked+.details {

  color: #919395!important;
}
#modal-overlay{
z-index:2;display:none;position:fixed;top:0;left:0;width:100%;height:120%;
}
#mod_setting .btn{
padding-top:0px;
padding-bottom:0px;
}


#close,#close2 {
  cursor: pointer;
  width: 200px;
  border: 1px solid #ccc;
  border-radius: 4px;
  text-align: center;
  padding: 12px;
  margin: 0px auto 0;
  background: #4caf50;
  z-index: 105;

  color: white;
}
#close{
float:left;
}#close2{
float:right;
}
#mask {
  background: rgba(0, 0, 0, 0.4);
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
  z-index: 101;
}

#modal {
  background: #fff;
  color: #555;
  width: 520px;
  padding: 25px;
  border-radius: 4px;
  position: fixed;
  top: 270px;
  left: 0;
  right: 0;
  margin: 0 auto;
  z-index: 102;
}
#mask.hidden {
  display: none;
}

#modal.hidden {
  display: none;
}`
document.head.appendChild(setting_css);

}



//MOD設定でプレイ前に必要な分を適用
function checkbox_effect(){
if(!is_played && play_mode == "normal"){
if(document.querySelector("[value=kana_type]").checked){
kana_mode = false
mode='kana'
keyboard='normal';
}else if(document.querySelector("[value=roma_type]").checked){
kana_mode = false
mode='roma'
keyboard='normal';

}else if(document.querySelector("[value=kanamode_type]").checked){
kana_mode = true
mode='kana'
keyboard='normal';

}else if(document.querySelector("[value=kanamode_mac_type]").checked){
kana_mode = true
mode='kana'
keyboard='mac';
}
}

if(document.querySelector(".playButton .under_line")!=null){
document.querySelector(".playButton .under_line").classList.remove('under_line');
}
document.querySelector("[name=mode_select]:checked").parentNode.classList.add('under_line');


    if(document.querySelector("[value=gauge]").checked){
document.getElementById("gauge").style.display = "block";
    }else{
document.getElementById("gauge").style.display = "none";
}

}



let miss_mode_life = "miss"//miss表示⇔life表示切り替え
let life_corrent_color=""//ライフ制のLife色
let keep_corrent_color="" //目標製確率の色(性格率維持モードで有効)

//MODメニューを開いた時、プレイ開始時に必要な文を適用
function checkbox_effect_mod_open_play(){
if(document.querySelector("[value=play_scroll]").checked){
document.getElementsByClassName("adjustment")[0].style.display = "block";
}else{
document.getElementsByClassName("adjustment")[0].style.display = "none";
}

if(document.querySelector("[value=perfect_mode]").checked){
document.getElementsByClassName("miss_limit")[0].style.display = "block";


if(document.querySelector("[value=life_corrent]").checked){
miss_mode_life="<span style='padding-left:5.35px;'>Life</span>"
if(life_corrent_color!="#FF4B00"){ life_corrent_color="gold"}
keep_corrent_color=localStorage.getItem('status_color')

}else{

if(keep_corrent_color!="#FF4B00"){keep_corrent_color="gold"}

life_corrent_color=localStorage.getItem('status_color')
miss_mode_life="miss"
}

}else{
life_corrent_color=localStorage.getItem('status_color')
keep_corrent_color=localStorage.getItem('status_color')
document.getElementsByClassName("miss_limit")[0].style.display = "none";
miss_mode_life="miss"
}



if(document.querySelector("[value=word_disable]").checked){
document.getElementById("word_making").style.display = "block";
}else{
document.getElementById("word_making").style.display = "none";
}

if(document.querySelector("[value=letter_scroll]").checked){
document.getElementsByClassName("scroll_amount")[0].style.display = "block";
}else{
document.getElementsByClassName("scroll_amount")[0].style.display = "none";
}

if(document.querySelector("[value=Interlocking_volume]").checked){
    combo_break.volume = (localStorage.getItem('volume_storage')/100)
    gameover_sound.volume = (localStorage.getItem('volume_storage')/100)
}else{
    combo_break.volume = document.querySelector("[name=effect_volume_miss]").value/100
    gameover_sound.volume = document.querySelector("[name=effect_volume_gameover]").value/100
}


if(document.querySelector("[value=Interlocking_volume]").checked){
for(let i=0;i<document.querySelectorAll("[name*='effect_volume']").length;i++){document.querySelectorAll("[name*='effect_volume']")[i].style.display = "none";}
}else{
for(let i=0;i<document.querySelectorAll("[name*='effect_volume']").length;i++){document.querySelectorAll("[name*='effect_volume']")[i].style.display = "block";}
}

}



var combo_break;
var gameover_sound
//効果音ロード
function load_sound(){
    combo_break = new Audio();
    combo_break.src = "/sounds/combo_break.mp3";
    combo_break.preload

    gameover_sound= new Audio();
    gameover_sound.src = "/sounds/gameover.mp3";
    gameover_sound.preload
}



window.AudioContext = window.AudioContext || window.webkitAudioContext;
var key_type = new AudioContext();
var miss_type = new AudioContext();
var clear_type = new AudioContext();



(function key_type_load(){
var request_key_type = new XMLHttpRequest();
request_key_type.open('GET', "/sounds/key_type.mp3", true);
request_key_type.responseType = 'arraybuffer';
request_key_type.onload = function() {
        key_type.decodeAudioData(request_key_type.response, function(buffer) {
                audio_buffer_key_type = buffer;
        }, function(){
                //エラー
        }
        );
};
request_key_type.send();
}());


function key_type_play(){
var key_type_gain = key_type.createGain();
var key_type_source = key_type.createBufferSource();
key_type_source.buffer = audio_buffer_key_type;
key_type_source.connect(key_type_gain);
key_type_gain.connect(key_type.destination);

if(document.querySelector("[value=Interlocking_volume]").checked){
key_type_gain.gain.value = (localStorage.getItem('volume_storage')/100)
}else{
key_type_gain.gain.value = document.querySelector("[name=effect_volume_type]").value/100
}

key_type_source.start(0);
}

(function miss_type_load(){
var request_miss_type = new XMLHttpRequest();
request_miss_type.open('GET', "/sounds/miss_type.mp3", true);
request_miss_type.responseType = 'arraybuffer';
request_miss_type.onload = function() {
        miss_type.decodeAudioData(request_miss_type.response, function(buffer) {
                audio_buffer_miss_type = buffer;
        }, function(){
                //エラー
        }
        );
};
request_miss_type.send();
}());
function miss_type_play(){
var miss_type_gain = miss_type.createGain();
var miss_type_source = miss_type.createBufferSource();
miss_type_source.buffer = audio_buffer_miss_type;
miss_type_source.connect(miss_type_gain);
miss_type_gain.connect(miss_type.destination);

if(document.querySelector("[value=Interlocking_volume]").checked){
miss_type_gain.gain.value = (localStorage.getItem('volume_storage')/100)
}else{
miss_type_gain.gain.value = document.querySelector("[name=effect_volume_type]").value/100
}

miss_type_source.start(0);
}

(function clear_type_load(){
var request_clear_type = new XMLHttpRequest();
request_clear_type.open('GET', "/sounds/clear_type.mp3", true);
request_clear_type.responseType = 'arraybuffer';
request_clear_type.onload = function() {
        clear_type.decodeAudioData(request_clear_type.response, function(buffer) {
                audio_buffer_clear_type = buffer;
        }, function(){
                //エラー
        }
        );
};
request_clear_type.send();
}());


function clear_type_play(){
var clear_type_gain = clear_type.createGain();
var clear_type_source = clear_type.createBufferSource();
clear_type_source.buffer = audio_buffer_clear_type;
clear_type_source.connect(clear_type_gain);
clear_type_gain.connect(clear_type.destination);

if(document.querySelector("[value=Interlocking_volume]").checked){
clear_type_gain.gain.value = (localStorage.getItem('volume_storage')/100)
}else{
clear_type_gain.gain.value = document.querySelector("[name=effect_volume_type]").value/100
}

clear_type_source.start(0);
}



/*
*@ページを開いたときのMOD追加機能処理 ここから---
**/
/////////////////////////////////////////////////////////////////////////////////////////////////









/////////////////////////////////////////////////////////////////////////////////////////////////
/**
*@ページ読み込み時のタイピングワード生成処理 ここから---
*/


const ranking_length = document.querySelectorAll(".player_ranking").length //ランキングの人数
let ranking_array = []; //ランキングのスコア

let movie_mm; //曲の長さ(分)
let movie_ss; //曲の長さ(秒)

//YouTubeプレイヤーの準備が完了した時に処理
onPlayerReady = function (event) {
if(!localStorage.getItem('volume_storage')){
    localStorage.setItem('volume_storage',70)
document.getElementById("volume").textContent = 70;
}else if (localStorage.getItem('volume_storage')) {
document.getElementById("volume").textContent = localStorage.getItem('volume_storage');
    player.setVolume(localStorage.getItem('volume_storage'));
}
for (let i = 0;i<ranking_length; i++) {ranking_array.unshift(parseFloat(document.querySelectorAll(".player_ranking")[i].textContent))};
        // ime.txtの読み込み解析
        $.ajax({
          type: 'GET',
	  url:"/ime.txt",
	    success:function (data){
              completeIme(data);
            },
            error:function() {
              alert("imeデータの読み込みに失敗しました");
            }
        });
      }



parseRomaMap = function (data){
        var result = new Array();
        var lines = data.split("\n");
const roma_length = lines.length
for (let s=0; s<roma_length; s++){
          result.push(lines[s].split("\t"));
        };
        result.push([" "," "]);
        return result;
      }


let ranking_Enter_flag = false; //Enterキーでランキングに登録するフラグ

parseLyrics = function (data) {
        var lines = data.split("\n");
        typing_array = new Array;
        lyrics_array = new Array;


const lines_length = lines.length
for (let s=1; s<lines_length; s++){
            a = lines[s].split("\t");
            if(a.length > 2){
              var arr = hiraganaToRomaArray(a[2]);
              typing_array.push(arr[0]);
              typing_array_kana.push(arr[1]);
              typing_array_roma.push(arr[2]);
              //a[2] = hiraganaToRoma(a[2]);
            } else {
              typing_array.push([]);
              typing_array_kana.push([]);
              typing_array_roma.push([]);
            }
            lyrics_array.push(a);
            if(a[1] == "end" ) {
movieTotalTime = parseInt(a[0]);
movie_mm =("00" + parseInt(parseInt(movieTotalTime) / 60)).slice(-2)
movie_ss = ("00" +(parseInt(movieTotalTime) - movie_mm * 60)).slice(-2)
var change_bar_base = document.createElement("progress");
    change_bar_base.setAttribute("max", movieTotalTime);
    change_bar_base.setAttribute("value", 0);
    change_bar_base.setAttribute("id", "bar_base");
    change_bar_base.setAttribute("class", "progress");
document.getElementById("bar_base").parentNode.replaceChild(change_bar_base,document.getElementById("bar_base"));

var changebar_input_base = document.createElement("progress");
    changebar_input_base.setAttribute("value", 0);
    changebar_input_base.setAttribute("id", "bar_input_base");
    changebar_input_base.setAttribute("class", "progress");
document.getElementById("bar_input_base").parentNode.replaceChild(changebar_input_base,document.getElementById("bar_input_base"));

//Enterキーで行うショートカットキー
window.addEventListener('keydown', function(){

if((document.activeElement.tagName != "INPUT" || document.activeElement.type == "radio") && event.key=="Enter"){
if(!is_played){document.activeElement.blur(); player.playVideo()}//Enterキーでプレイ開始
else if(finished&& !ranking_Enter_flag && play_mode=="normal" &&document.querySelector("#result_comment [type=button]")!=null ){//曲終了、Enterキーで記録送信
            submit_score();
            ranking_Enter_flag = true;
}
}

});

break;

          }
        };

        return lyrics_array;

      }


//typing_array,typing_array_roma,typing_array_kanaの生成
let abridgement_word_length = 0


hiraganaToRomaArray = function (str) {

        var str_array = [];
        var kana_array = [];
        var roma_array = [];

const romaMap_length = romaMap.length
for (let i=0; i<romaMap_length; i++){
          if(romaMap[i].length > 1){
            str = str.replace(RegExp(romaMap[i][0],"g"),"\t"+i+"\t");
          }
        };
const str_length = (str.split(/\s+/)).length
str = str.split(/\s+/)
for (let i=0; i<str_length; i++){
          if(str[i] != "") {
            if(str.length > 0 && romaMap[parseInt(str[i])]){
              kana_array.push(romaMap[parseInt(str[i])][0]);
              str_array.push(romaMap[parseInt(str[i])].slice(1));
              roma_array.push(romaMap[parseInt(str[i])][1]);

if( localStorage.getItem('oomoji_shift') == "true" && /[A-ZA-Z]/.test(kana_array[kana_array.length-1]) ){
roma_array.splice(-1,1,kana_array[kana_array.length-1])
   }
//「~」はハイフンで入力できる仕様なので「ー」に変換。設定で全角長音記号にも対応

if(localStorage.getItem('kigou_disable') == "false" && kana_array[kana_array.length-1]=="~"){
roma_array.splice(-1,1,'~')
str_array[str_array.length-1][0] = '~'
}else if(localStorage.getItem('kigou_disable') == "true" && kana_array[kana_array.length-1]=="~"){
kana_array[kana_array.length-1]="ー"
roma_array.splice(-1,1,'-')
str_array[str_array.length-1][0] = '-'
}

            } else if(localStorage.getItem('kigou_disable') != "true"||localStorage.getItem('word_disable') != "true"){
for (let v=0; v<str[i].length; v++){
              kana_array.push(str[i][v].replace(/…/g,"...")
.replace(/‥/g,"..")
.replace(/・/g,"・"));
              str_array.push([str[i][v]
.replace(/、/g,",")
.replace(/。/g,".")
.replace(/!/g,"!")
.replace(/?/g,"?")
.replace(/・/g,"\/")
.replace(/・/g,"\/")
.replace(/@/g,"@")
.replace(/”/g,"\"")
.replace(/#/g,"#")
.replace(/$/g,"\$")
.replace(/%/g,"%")
.replace(/&/g,"&")
.replace(/’/g,"'")
.replace(/(/g,"\(")
.replace(/)/g,"\)")
.replace(/¥/g,"\\")
.replace(/|/g,"\|")
.replace(/「/g,"\[")
.replace(/」/g,"\]")
.replace(/{/g,"\{")
.replace(/}/g,"\}")
.replace(/`/g,"`")
.replace(/*/g,"\*")
.replace(/+/g,"\+")
.replace(/:/g,":")
.replace(/;/g,";")
.replace(/_/g,"_")
.replace(/</g,"<")
.replace(/>/g,">")
.replace(/=/g,"=")
.replace(/^/g,"\^")
.replace(/…/g,"...")
.replace(/‥/g,"..")
.replace(/←/g,"zh")
.replace(/↓/g,"zj")
.replace(/↑/g,"zk")
.replace(/→/g,"zl")
.replace(/『/g,"z[")
.replace(/』/g,"z]")
.replace(/ヰ/g,"wi")
.replace(/ゐ/g,"wi")
.replace(/ヱ/g,"we")
.replace(/ゑ/g,"we")]);
              roma_array.push(str[i][v].replace(/、/g,",")
.replace(/。/g,".")
.replace(/!/g,"!")
.replace(/?/g,"?")
.replace(/・/g,"\/")
.replace(/・/g,"\/")
.replace(/@/g,"@")
.replace(/”/g,"\"")
.replace(/#/g,"#")
.replace(/$/g,"\$")
.replace(/%/g,"%")
.replace(/&/g,"&")
.replace(/’/g,"'")
.replace(/(/g,"\(")
.replace(/)/g,"\)")
.replace(/¥/g,"\\")
.replace(/|/g,"\|")
.replace(/「/g,"\[")
.replace(/」/g,"\]")
.replace(/{/g,"\{")
.replace(/}/g,"\}")
.replace(/`/g,"`")
.replace(/*/g,"\*")
.replace(/+/g,"\+")
.replace(/:/g,":")
.replace(/;/g,";")
.replace(/_/g,"_")
.replace(/</g,"<")
.replace(/>/g,">")
.replace(/=/g,"=")
.replace(/^/g,"\^")
.replace(/…/g,"...")
.replace(/‥/g,"..")
.replace(/←/g,"zh")
.replace(/↓/g,"zj")
.replace(/↑/g,"zk")
.replace(/→/g,"zl")
.replace(/『/g,"z[")
.replace(/』/g,"z]")
.replace(/ヰ/g,"wi")
.replace(/ゐ/g,"wi")
.replace(/ヱ/g,"we")
.replace(/ゑ/g,"we"));

//全角記号・三点リーダを対応

//ひらがなの直後のカンマ、ピリオドを句読点に変換(三点リーダは変換されない)
if(/[ぁ-ん|ヴ|ゔ|ー|゛]/.test(kana_array[kana_array.length-2]) && str[i][v+1] != "." && str[i][v] == "."){
kana_array.splice(-1,1,'。')
}
if(/[ぁ-ん|ヴ|ゔ|ー|゛]/.test(kana_array[kana_array.length-2]) && str[i][v+1] != "," && str[i][v] == ","){
kana_array.splice(-1,1,'、')
}

            }
}else{
abridgement_word_length += str[i].replace(/、/g,",")
.replace(/。/g,".")
.replace(/!/g,"!")
.replace(/?/g,"?")
.replace(/・/g,"\/")
.replace(/・/g,"\/")
.replace(/@/g,"@")
.replace(/”/g,"\"")
.replace(/#/g,"#")
.replace(/$/g,"\$")
.replace(/%/g,"%")
.replace(/&/g,"&")
.replace(/’/g,"'")
.replace(/(/g,"\(")
.replace(/)/g,"\)")
.replace(/¥/g,"\\")
.replace(/|/g,"\|")
.replace(/「/g,"\[")
.replace(/」/g,"\]")
.replace(/{/g,"\{")
.replace(/}/g,"\}")
.replace(/`/g,"`")
.replace(/*/g,"\*")
.replace(/+/g,"\+")
.replace(/:/g,":")
.replace(/;/g,";")
.replace(/_/g,"_")
.replace(/</g,"<")
.replace(/>/g,">")
.replace(/=/g,"=")
.replace(/^/g,"\^")
.replace(/…/g,"...")
.replace(/‥/g,"..")
.replace(/←/g,"zh")
.replace(/↓/g,"zj")
.replace(/↑/g,"zk")
.replace(/→/g,"zl")
.replace(/『/g,"z[")
.replace(/』/g,"z]")
.replace(/ヰ/g,"wi")
.replace(/ゐ/g,"wi")
.replace(/ヱ/g,"we")
.replace(/ゑ/g,"we").length
}


//半角スペース無効設定有効で半角スペースを除去。
if(localStorage.getItem('word_disable') == "true"&&localStorage.getItem('space_disable') == "true" && kana_array[kana_array.length-1] == " "){
kana_array.pop()
str_array.pop()
roma_array.pop()
abridgement_word_length ++
}

//「あいうえお、なにぬねの」など打鍵パターンが変化する文字がkana_arrayに追加されたときに、前回追加した「n」を「nn」に置き換えます。
//正規表現にマッチする文字は[あ行、な行、や行、ん、アルファベット]
if(kana_array[kana_array.length-2]=="ん" && /あ|い|う|え|お|な|に|ぬ|ね|の|や|ゆ|よ|ん|[a-zA-Za-zA-Z]/.test(kana_array[kana_array.length-1])){
roma_array.splice(-2,1,'nn')
str_array[str_array.length-2][0] = 'nn'

//それ以外の文字でもnnの入力を可能にする
}else if(kana_array[kana_array.length-2]=="ん" && kana_array[kana_array.length-1]){
str_array[str_array.length-1].splice(1, 0, 'n'+str_array[str_array.length-1][0])
}

        }
        };

//kana_array最後の文字が「ん」だった場合も[nn]に置き換えます。
if(kana_array[kana_array.length-1] == "ん"){
roma_array.splice(-1,1,'nn')
str_array[str_array.length-1][0] = 'nn'
}
return [str_array, kana_array, roma_array];
}




var total_notes=0;
var line_length=0;

var total_notes_kana_mode = 0;
var kana_score_per_char = 0;
var roma_score_per_char = 0;


var difficulty_max = 0
var difficulty_average = 0;

var difficulty_max_kana = 0
var difficulty_average_kana = 0;

var line_speed_ranking=[];//打鍵速度が早い順で[ライン番号,ライン打鍵数,ラインの必要打鍵速度]が入る



//配点基準・必要速度を計算・表示
getScorePerChar=function () {
        c = 0.0;

line_notes_roma=0
line_notes_kana=0
line_daku_handaku=0
line_speed=0
kana_daku_handaku_length = 0
const typing_array_length = typing_array.length
for (let i=0; i<typing_array_length; i++){
//typing_arrayのi番号がend行と同じ番号なら総合打鍵数に含まない
if(lyrics_array[i][1]!='end' && typing_array[i] != ''){


//ラインの数・ライン時間
if(logcount == 0){logcount = i+1}
line_length++;
line_speed=lyrics_array[i+1][0]-lyrics_array[i][0]

//かな入力
line_daku_handaku=(typing_array_kana[i].join('').match( /[ゔ|が|ぎ|ぐ|げ|ご|ざ|じ|ず|ぜ|ぞ|だ|ぢ|づ|で|ど|ば|び|ぶ|べ|ぼ|ぱ|ぴ|ぷ|ぺ|ぽ]/g ) || [] ).length
kana_daku_handaku_length += line_daku_handaku
line_notes_kana=typing_array_kana[i].join('').length
total_notes_kana_mode += (line_notes_kana+line_daku_handaku)


//ローマ字入力
line_notes_roma = typing_array_roma[i].join('').length
total_notes += line_notes_roma


//かな入力ライン速度
if( (line_notes_kana+line_daku_handaku)/line_speed > difficulty_max_kana ){
difficulty_max_kana = ((line_notes_kana+line_daku_handaku)/line_speed)
}
difficulty_average_kana += (line_notes_kana+line_daku_handaku)/line_speed

line_speed_ranking.push([i ,line_notes_roma, Number((line_notes_roma/line_speed).toFixed(2))])

//ローマ字入力ライン速度
difficulty_average += line_notes_roma/line_speed

}else if(lyrics_array[i][1]=='end'){
        //line_speed_rankingを打鍵速度が速い順に降順でソート
        line_speed_ranking.sort( function(a,b){return(b[2]-a[2]);} )
//if(line_speed_ranking.length>11){
//line_speed_ranking.splice(11-line_speed_ranking.length,9999)
//}
//var sum = 0;
//$.each(line_speed_ranking, function(i, line_speed){
//sum += line_speed[2]

//})
difficulty_max=line_speed_ranking[0][2]

//        line_speed_ranking.sort( function(a,b){return(a[0]-b[0]);} )
//console.log(line_speed_ranking)
//console.log(sum)
kana_score_per_char = 200000 / ((total_notes_kana_mode-kana_daku_handaku_length)+abridgement_word_length)
roma_score_per_char = 200000 / (total_notes + abridgement_word_length)
difficulty_ave=(difficulty_average/line_length).toFixed(2)
difficulty_ave_kana=(difficulty_average_kana/line_length).toFixed(2)
difficulty_kana=difficulty_max_kana.toFixed(2)

if (localStorage.getItem('initial_speed')) {

let initial_speed_array = localStorage.getItem('initial_speed');
initial_speed_array = JSON.parse(initial_speed_array);
initial_speed1=initial_speed_array[0]
initial_speed2=initial_speed_array[1]
initial_speed3=initial_speed_array[2]
initial_speed4=initial_speed_array[3]
initial_speed5=initial_speed_array[4]
document.getElementById("initial_speed1").textContent = initial_speed_array[0].toFixed(2);
document.getElementById("initial_speed2").textContent = initial_speed_array[1].toFixed(2);
document.getElementById("initial_speed3").textContent = initial_speed_array[2].toFixed(2);
document.getElementById("initial_speed4").textContent = initial_speed_array[3].toFixed(2);
document.getElementById("initial_speed5").textContent = initial_speed_array[4].toFixed(2);

if(document.querySelector(".movietitle span").textContent.replace(/[^0-9^\.]/g,"") == 1){
       play_speed = initial_speed_array[0];
       player.setPlaybackRate(initial_speed_array[0]);
document.getElementById("playspeed").textContent = initial_speed_array[0].toFixed(2)+"倍速";
document.getElementById("speed").textContent = initial_speed_array[0].toFixed(2);
document.getElementById("default_speed").textContent = initial_speed_array[0].toFixed(2)+"倍速";
}else if(document.querySelector(".movietitle span").textContent.replace(/[^0-9^\.]/g,"") == 2){
       play_speed = initial_speed_array[1];
       player.setPlaybackRate(initial_speed_array[1]);
document.getElementById("playspeed").textContent = initial_speed_array[1].toFixed(2)+"倍速";
document.getElementById("speed").textContent = initial_speed_array[1].toFixed(2);
document.getElementById("default_speed").textContent = initial_speed_array[1].toFixed(2)+"倍速";
}else if(document.querySelector(".movietitle span").textContent.replace(/[^0-9^\.]/g,"") == 3){
       play_speed = initial_speed_array[2];
       player.setPlaybackRate(initial_speed_array[2]);
document.getElementById("playspeed").textContent = initial_speed_array[2].toFixed(2)+"倍速";
document.getElementById("speed").textContent = initial_speed_array[2].toFixed(2);
document.getElementById("default_speed").textContent = initial_speed_array[2].toFixed(2)+"倍速";
}else if(document.querySelector(".movietitle span").textContent.replace(/[^0-9^\.]/g,"") == 4){
       play_speed = initial_speed_array[3];
       player.setPlaybackRate(initial_speed_array[3]);
document.getElementById("playspeed").textContent = initial_speed_array[3].toFixed(2)+"倍速";
document.getElementById("speed").textContent = initial_speed_array[3].toFixed(2);
document.getElementById("default_speed").textContent = initial_speed_array[3].toFixed(2)+"倍速";
}else if(document.querySelector(".movietitle span").textContent.replace(/[^0-9^\.]/g,"") == 5){
       play_speed = initial_speed_array[4];
       player.setPlaybackRate(initial_speed_array[4]);
document.getElementById("playspeed").textContent = initial_speed_array[4].toFixed(2)+"倍速";
document.getElementById("speed").textContent = initial_speed_array[4].toFixed(2);
document.getElementById("default_speed").textContent = initial_speed_array[4].toFixed(2)+"倍速";
}

}
//かな入力モード
if(document.querySelector("[name=mode_select]:checked").value == "kanamode_type"||document.querySelector("[name=mode_select]:checked").value == "kanamode_mac_type"){
if(localStorage.getItem('word_disable') == "true" && (localStorage.getItem('space_disable') == "true" || localStorage.getItem('kigou_disable') == "true") ){
document.querySelector("#difficult > span").innerHTML = '<span title="打鍵数"><i class="fas fa-drum" style="backgroundcolor=:#441188; border-radius: 16px;"></i> '+total_notes_kana_mode + '打</span> <span title="ライン数"><i class="fas fa-scroll" style=""></i>'+line_length+'ライン</span> <span title="長さ"><i class="far fa-clock" style=""></i>'+movie_mm+':'+movie_ss+'</span> <span title="必要入力スピード"><i class="fas fa-tachometer-alt" style=""></i>平均'+difficulty_ave_kana+'打/秒, 最高'+difficulty_kana+'打/秒</span> <span title="省略設定詳細">(省略文字数:'+abridgement_word_length+', 最大点数:'+(((kana_score_per_char * (total_notes_kana_mode-kana_daku_handaku_length))/20)/100).toFixed(2)+'</span>';
}else{
document.querySelector("#difficult > span").innerHTML = '<span title="打鍵数"><i class="fas fa-drum" style="backgroundcolor=:#441188; border-radius: 16px;"></i> '+total_notes_kana_mode + '打</span> <span title="ライン数"><i class="fas fa-scroll" style=""></i>'+line_length+'ライン</span> <span title="長さ"><i class="far fa-clock" style=""></i>'+movie_mm+':'+movie_ss+'</span> <span title="必要入力スピード"><i class="fas fa-tachometer-alt" style=""></i>平均'+difficulty_ave_kana+'打/秒, 最高'+difficulty_kana+'打/秒</span>';
}
}else{
if(localStorage.getItem('word_disable') == "true" && (localStorage.getItem('space_disable') == "true" || localStorage.getItem('kigou_disable') == "true") ){
document.querySelector("#difficult > span").innerHTML = '<span title="打鍵数"><i class="fas fa-drum" style="backgroundcolor=:#441188; border-radius: 16px;"></i> '+total_notes + '打</span> <span title="ライン数"><i class="fas fa-scroll" style=""></i>'+line_length+'ライン</span> <span title="長さ"><i class="far fa-clock" style=""></i>'+movie_mm+':'+movie_ss+'</span> <span title="必要入力スピード"><i class="fas fa-tachometer-alt" style=""></i>平均'+difficulty_ave+'打/秒, 最高'+difficulty_max+'打/秒</span> <span title="省略設定詳細">(省略文字数:'+abridgement_word_length+', 最大点数:'+(((roma_score_per_char * total_notes)/20)/100).toFixed(2)+')</span>';
}else{
document.querySelector("#difficult > span").innerHTML = '<span title="打鍵数"><i class="fas fa-drum" style="backgroundcolor=:#441188; border-radius: 16px;"></i> '+total_notes + '打</span> <span title="ライン数"><i class="fas fa-scroll" style=""></i>'+line_length+'ライン</span> <span title="長さ"><i class="far fa-clock" style=""></i>'+movie_mm+':'+movie_ss+'</span> <span title="必要入力スピード"><i class="fas fa-tachometer-alt" style=""></i>平均'+difficulty_ave+'打/秒, 最高'+difficulty_max+'打/秒</span>';
}
}


break;
}
};
        return roma_score_per_char;
      }







/*
*@ページ読み込み時のタイピングワード生成処理 ここまで---
**/
/////////////////////////////////////////////////////////////////////////////////////////////////











/////////////////////////////////////////////////////////////////////////////////////////////////
/**
*@プレイ開始前準備の関数変更 ここから---
*/



//statusを構成する要素追加
update_status = function(){

keystroke_update()
if(document.querySelector("[value=status_mode_not_break]").checked){
document.getElementById("status").innerHTML = "<span class='score'>"+((score/20)/100).toFixed(2)+"</span>"+
"<span class='miss'><span id='miss_text'>"+typing_miss_count + "</span>miss<span id='life_corrent_text' style='font-size:90%;color:"+life_corrent_color+";'>"+life_corrent+"</span></span><span class='acc' style='color:"+keep_corrent_color+";'><span style='font-size:75%;font-weight:normal;'>正確率:</span><span id='corrent_text' style='font-size:85%;'>"+(correct.toFixed(1))+"%"+keep_corrent+"</span></span>"+
"<span class='combo_counter'>"+combo+"combo</span>"+
"<span class='type_counter'><span id='type_counter_text'>"+typing_count + "</span><span style='font-weight:normal;'>打</span></span><span class='escape_counter' style='font-size:80%;'>["+escape_word_length + "]esc<br></span>"+
"<span class='clear_counter'>"+complete_count + "<span style='font-size:90%;'>clear</span></span><span class='line_count'>["+(line_length-(failer_count+complete_count))+"]<span style='font-size:90%;'>line</span><br></span>"+
"<span class='rank'>"+(ranking_array.length +1) + "<span style='font-weight:normal;'>位</span></span><span class='typing_speed'>[<span id='type_speed'>"+typing_speed.toFixed(2)+"</span><span style='font-weight:normal;'>打/秒</span>]</span>";

}else{

document.getElementById("status").innerHTML = "<div id=statu1dan style='display:-webkit-box;'>"+
"<span class='score'style='width:227px;'><span class='status_label' style='font-size:75%;'> Score</span><span class='score_text' style='margin-left: 3px;'>"+((score/20)/100).toFixed(2)+"</span></span>"+
"<span class='miss' style='width:137px;color:"+life_corrent_color+";'><span class='status_label' style='font-size:75%;'>"+miss_mode_life+"</span><span class='status_text' style='margin-left: 3px;'>"+life_corrent +"</span></span>"+
"<span class='combo_counter' style='width:166px;'><span class='status_label' style='font-size:75%;'>Combo</span><span class='status_text'style='margin-left: 3px;'>"+combo+"</span></span>"+
"<span class='typing_speed'style='width:229px;'><span class='status_label' style='font-size:75%;font-weight:normal;'>打/秒</span><span class='status_text' id='type_speed' style='margin-left: 3px;'>" +typing_speed.toFixed(2)+"</span></span>"+
"<span class='line_count'><span class='status_label' style='font-size:75%;'>Line</span><span class='line_text' style='margin-left: 3px;'>" +(line_length-(failer_count+complete_count))+"</span></span>"+
"</div><div id=statu2dan style='display:-webkit-box;margin-top:10px;'>"+
"<span style='width: 215px;display:block;'><span class='rank'><span class='status_label' style='font-size:75%;'> Rank</span><span class='score_text2'style='margin-left: 7px;'>"+(ranking_array.length +1) + "<span style='font-weight:normal;'>位</span></span></span>"+
"<span class='status_label acc' style='position: relative;top:-11px;left:1px;float:right;width:0px;color:"+keep_corrent_color+";font-size:65%;font-weight:normal;'>"+keep_corrent+"</span></span>"+
"<span class='acc' style='width: 164px;color:"+keep_corrent_color+";'><span class='status_label' style='font-size:65%;font-weight:normal;'>正確率</span><span style='font-size:90%;margin-left: 3px;'class='status_text2'>"+correct.toFixed(1)+"%</span></span>"+
"<span class='type_counter' style='width:161px;'><span class='status_label' style='font-size:75%;'>Type</span><span class='status_text2'style='margin-left: 3px;'>"+typing_count + "</span></span>"+
"<span class='escape_counter' style='width:212px;'><span class='status_label' style='font-size:75%;'>Esc</span><span class='status_text2'style='margin-left: 3px;'>"+escape_word_length + "</span></span>"+
"<span class='clear_counter'><span class='status_label' style='font-size:75%;'>Clear</span><span class='line_text2'style='margin-left: 3px;'>"+complete_count + "</span></span></div>";
}
update_skip();

}



let control_default_size
//プレイ開始時に各機能で必要なDOMを追加
function play_preparation(){

window.addEventListener('resize',function(){
if(!finished&&document.querySelector("[value=play_scroll]").checked&&!navigator.userAgent.match(/(iPhone|iPod|iPad|Android.*Mobile)/i)){
window.scrollTo({top: (document.documentElement.scrollTop+document.getElementById("controlbox").getBoundingClientRect().top+document.getElementById("controlbox").clientHeight+Number(localStorage.getItem('scroll_adjustment1'))-document.documentElement.clientHeight)})
}
});
speed=Number(document.getElementById("speed").textContent)
document.querySelector(".status .nav").children[0].classList.add('under_line');
document.querySelector(".status .nav").children[1].classList.remove('under_line');
document.getElementById("kashi").classList.remove('text-white');
document.getElementById("kashi").classList.remove('mt-3');
document.getElementById("kashi_next").classList.remove('mt-3');
document.getElementById("kashi_next").classList.remove('text-muted');

var skip_guide_html = document.createElement('div');
    skip_guide_html.setAttribute("id", "skip_guide");
    skip_guide_html.setAttribute("style", "font-weight:400;text-align:left;");
    skip_guide_html.innerHTML = ""
document.getElementById("kashi_next").parentNode.insertBefore(skip_guide_html, document.getElementById("kashi_next").nextElementSibling);

var total_time_html = document.createElement('div');
    total_time_html.setAttribute("id", "total_time");
    total_time_html.setAttribute("style", "font-weight: 600;color: #fff;text-align: right;height: 0px;font-family: sans-serif;");
    total_time_html.innerHTML = "00:00 / " + movie_mm+':'+movie_ss
document.getElementById("kashi_next").parentNode.insertBefore(total_time_html, document.getElementById("kashi_next").nextElementSibling);


var next_kpm_html = document.createElement('div');
    next_kpm_html.setAttribute("id", "next_kpm");
    next_kpm_html.setAttribute("style", "font-size:12.5px;font-weight: 500;text-align:left;");
    next_kpm_html.innerHTML = "&#8203;"
document.getElementById("kashi_next").parentNode.insertBefore(next_kpm_html, document.getElementById("kashi_next").nextElementSibling);

var combo_stat2_html = document.createElement('span');
    combo_stat2_html.setAttribute("id", "combo_stat2");
    combo_stat2_html.setAttribute("style", "display: inline-block;text-align: center;font-weight:600;position: absolute;top: -7px;font-size: 20px;font-family: sans-serif;");
    combo_stat2_html.innerHTML = "&#8203;"
document.getElementById("bar_input_base").parentNode.insertBefore(combo_stat2_html, document.getElementById("bar_input_base"));

var complete_html = document.createElement("div");
    complete_html.setAttribute("style", "position: absolute;width: 100%;top: -3px;text-align: center;font-size: 140%;letter-spacing: 2px;font-weight: 600;font-family: sans-serif;");
    complete_html.setAttribute("id", "complete_effect");
document.getElementById("bar_input_base").parentNode.insertBefore(complete_html, document.getElementById("bar_input_base"));

var line_remaining_time_html = document.createElement('div');
    line_remaining_time_html.setAttribute("id", "line_remaining_time");
    line_remaining_time_html.setAttribute("style", "font-family: sans-serif;padding-top:5px;font-size: 13px;font-weight: 600;color: #fff;text-align: right;");

if(document.querySelector("[value=line_hidden]").checked){
    line_remaining_time_html.innerHTML = "<span id='line_speed'>0.00打/秒</span> - <span id='remaining_time'>latency:0.000ms</span>"
}else{
    line_remaining_time_html.innerHTML = "<span id='line_speed'>0.00打/秒</span> - <span id='remaining_time'>残り0.0秒</span>"
}
document.getElementById("bar_input_base").parentNode.insertBefore(line_remaining_time_html, document.getElementById("bar_input_base"));

var count_anime_html = document.createElement('div');
    count_anime_html.setAttribute("id", "count_anime");
    count_anime_html.setAttribute("style", "font-size:45px;font-weight: 600;text-align:center;height: 0px;position:relative;top:-15px;");
    count_anime_html.innerHTML = ""
document.getElementById("kashi").parentNode.insertBefore(count_anime_html, document.getElementById("kashi"));

document.getElementById("esckey").style.display='none';
document.getElementById("bar_input_base").style.marginTop = "0";
document.getElementById("bar_base").style.marginTop = "0";
document.getElementById("kashi").style.color=document.querySelector("[name=lyric_color]").value;
document.getElementById("kashi_next").style.marginBottom="0";
document.getElementById("kashi_next").style.color=document.querySelector("[name=next_lyrics_color]").value;



player.difftime = Number(localStorage.getItem('diff_storage'))
if (document.getElementById("kashi_sub") == null) {
// DOM要素がない場合は初期化
var kashi_roma_html = document.createElement('div');
    kashi_roma_html.setAttribute("id", "kashi_sub");
    kashi_roma_html.setAttribute("style", "font-weight:600;");
    kashi_roma_html.innerHTML = "&#8203;"
document.getElementById("kashi_roma").parentNode.insertBefore(kashi_roma_html, document.getElementById("kashi_roma").nextElementSibling);
document.getElementById("kashi_roma").innerHTML = '&#8203;';
document.getElementById("kashi_roma").classList.add('gothicfont')
document.getElementById("kashi_sub").classList.add('gothicfont')
}

document.getElementById("kashi").innerHTML = "<ruby>&#8203;<rt>&#8203;</rt></ruby>&nbsp;";
document.getElementById("kashi_next").innerHTML = "<ruby>&#8203;<rt>&#8203;</rt></ruby>&nbsp;";

control_default_size=(document.documentElement.scrollTop+document.getElementById("controlbox").getBoundingClientRect().top+document.getElementById("controlbox").clientHeight)
checkbox_effect_mod_open_play()
checkbox_effect_play()
}

function is_in_sight(jq_obj) {
	var scroll_top    = window.scrollY;
	var scroll_bottom = scroll_top + window.innerHeight;
	var target_top    = document.documentElement.scrollTop+jq_obj.getBoundingClientRect().top;
	var target_bottom = target_top + parseInt(window.getComputedStyle(jq_obj).height);
    if (scroll_bottom > target_top) {

setTimeout(function (){
if(document.querySelector("[value=play_scroll]").checked){
window.scrollTo({
    top: (document.documentElement.scrollTop+document.getElementById("controlbox").getBoundingClientRect().top+document.getElementById("controlbox").clientHeight+Number(localStorage.getItem('scroll_adjustment1'))-document.documentElement.clientHeight)
})
}},50);

}
}


onPlayerStateChange = function (event) {
        if(player.getPlayerState() == 1) {//再生(player.playVideo)

          if (finished) {
            player.stopVideo();//再生できなくする
              return;
          }
            else if(!is_played) {//プレイ開始
            is_played = true;
              play_preparation()
            play_movie();
            start_movie();
              document.activeElement.blur();
is_in_sight(document.getElementById("youtube-movie"));

          } else {//ポーズから復帰
              document.activeElement.blur();
            createjs.Ticker.addEventListener("tick", playheadUpdate);
              window.removeEventListener('keydown',esc_play_movie,true);

            if(kana_mode) {
              window.addEventListener('keydown',keydownfunc_kana,true);
            } else {
              window.addEventListener('keydown',keydownfunc,true);
            }
          }

        } else if(player.getPlayerState() == 0 || player.getPlayerState() == -1 && finished){//終了(player.stopVideo)
          finished = true;
not_play_event()
type_per_min=typing_speed*60
line_result_check()
typing_result_generator()
          finish_comment();
        } else if(player.getPlayerState() == 2) {//一時停止(player.pauseVideo)
              document.activeElement.blur();
          if (!stop_time_flag) { //練習モードで止まってない
              window.addEventListener('keydown',esc_play_movie,true);
              not_play_event()
          }
        }
      }

function esc_play_movie(){
if(event.key=="Escape"){//Escでポーズ解除
    player.playVideo()
event.preventDefault();
}
}


play_movie = function () {
        createjs.Ticker.addEventListener("tick", playheadUpdate);
        createjs.Ticker.timingMode = createjs.Ticker.RAF;
        if(kana_mode) {
score_per_char = kana_score_per_char
          window.addEventListener('keydown',keydownfunc_kana,true);
        } else {
          window.addEventListener('keydown',keydownfunc,true);
        }
document.getElementById("kashi_area").style.display = "block"
document.getElementById("kashi").style.display = "block"
document.getElementById("kashi_roma").style.display = "block"
document.getElementById("kashi_next").style.display = "block"

document.getElementById("playBotton1").style.display = "none"
document.getElementById("playBotton2").style.display = "none"

document.getElementById("playBotton3").style.display = "none"

//かな入力モードが出ない時があるため変更不可
        $('#playBotton4').hide();
        $('#playBotton5').hide();
    add_line_typingword()
      }




/**
*@プレイ前準備の関数変更 ここまで---
*/
/////////////////////////////////////////////////////////////////////////////////////////////////










/////////////////////////////////////////////////////////////////////////////////////////////////
/**
*@MOD設定保存・反映 ここから---
*/





//チェックボックス状態・value値をlocalstorageに保存
function setting_save() {
if(document.querySelector("[name=color_theme]").value =="デフォルト"){
color_default()
}else if(document.querySelector("[name=color_theme]").value =="先頭の文字を赤く強調"){
letter_red()
}
document.querySelector("[name=color_theme]").selectedIndex = 0


//チェックボックス設定保存 判別(サーバーに保存する機能ができ次第削除)ここから
    localStorage.setItem('sub',document.querySelector("[value=sub]").checked)
    localStorage.setItem('eng_highlight',document.querySelector("[value=eng_highlight]").checked)
    localStorage.setItem('letter_scroll',document.querySelector("[value=letter_scroll]").checked)
    localStorage.setItem('oomoji_shift',document.querySelector("[value=oomoji_shift]").checked)
    localStorage.setItem('mizumasi',document.querySelector("[value=mizumasi]").checked)
    localStorage.setItem('line_hidden',document.querySelector("[value=line_hidden]").checked)
    localStorage.setItem('type_sound',document.querySelector("[value=type_sound]").checked)
    localStorage.setItem('miss_sound',document.querySelector("[value=miss_sound]").checked)
    localStorage.setItem('miss_sound_top',document.querySelector("[value=miss_sound_top]").checked)
    localStorage.setItem('clear_sound',document.querySelector("[value=clear_sound]").checked)
    localStorage.setItem('combo_break_sound',document.querySelector("[value=combo_break_sound]").checked)
    localStorage.setItem('Interlocking_volume',document.querySelector("[value=Interlocking_volume]").checked)
    localStorage.setItem('gameover_sound',document.querySelector("[value=gameover_sound]").checked)
    localStorage.setItem('word_disable',document.querySelector("[value=word_disable]").checked)
    localStorage.setItem('space_disable',document.querySelector("[value=space_disable]").checked)
    localStorage.setItem('kigou_disable',document.querySelector("[value=kigou_disable]").checked)
    localStorage.setItem('anime_count',document.querySelector("[value=anime_count]").checked)
    localStorage.setItem('count_animation',document.querySelector("[value=count_animation]").checked)
    localStorage.setItem('skip_guide',document.querySelector("[value=skip_guide]").checked)
    localStorage.setItem('skip_key',document.querySelector("[value=skip_enter]").checked)
    localStorage.setItem('word_result',document.querySelector("[value=word_result]").checked)
    localStorage.setItem('not_video',document.querySelector("[value=not_video]").checked)
    localStorage.setItem('perfect_mode',document.querySelector("[value=perfect_mode]").checked)
    localStorage.setItem('miss_limit_mode',document.querySelector("[value=keep_corrent]").checked)
    localStorage.setItem('gauge',document.querySelector("[value=gauge]").checked)
    localStorage.setItem('combo_display',document.querySelector("[value=combo_display]").checked)
    localStorage.setItem('combo_animation',document.querySelector("[value=combo_animation]").checked)
    localStorage.setItem('next_text',document.querySelector("[value=next_text_reading]").checked)
    localStorage.setItem('play_scroll1',document.querySelector("[value=play_scroll]").checked)
    localStorage.setItem('status_mode',document.querySelector("[value=status_mode_new_line]").checked)
    localStorage.setItem('miss_on',document.querySelector("[value=miss_on]").checked)


//数値入力フォーム
    localStorage.setItem('mode_select1',document.querySelector("[name=mode_select]:checked").value)
    localStorage.setItem('ef_volume_type',document.querySelector("[name=effect_volume_type]").value)
    localStorage.setItem('ef_volume_miss',document.querySelector("[name=effect_volume_miss]").value)
    localStorage.setItem('ef_volume_clear',document.querySelector("[name=effect_volume_clear]").value)
    localStorage.setItem('ef_volume_combo_break',document.querySelector("[name=effect_volume_combo_break]").value)
    localStorage.setItem('effect_volume_gameover',document.querySelector("[name=effect_volume_gameover]").value)
    localStorage.setItem('miss_limit', document.querySelector("[name=miss_limit]").value)
    localStorage.setItem('letter_scroll_kana',document.querySelector("[name=letter_scroll_kana]").value)
    localStorage.setItem('letter_scroll_roma',document.querySelector("[name=letter_scroll_roma]").value)
    localStorage.setItem('font_size_kana',document.querySelector("[name=font_size_kana]").value)
    localStorage.setItem('font_size_roma',document.querySelector("[name=font_size_roma]").value)
    localStorage.setItem('playarea_radius', document.querySelector("[name=playarea_radius]").value)
    localStorage.setItem('futidori_theme',document.querySelector("[name=futidori_theme]").value)
    localStorage.setItem('futidori_border-width',document.querySelector("[name=futidori_border-width]").value)


//status表示・非表示チェックボックス
if(document.querySelector("[value=score]").checked){
    localStorage.setItem('score1',"display:block;")
}else{
if(document.querySelector("[value=status_mode_new_line]").checked){
    localStorage.setItem('score1',"visibility:hidden;display:block;")
}else{
    localStorage.setItem('score1',"display:none;")
}
}if(document.querySelector("[value=miss]").checked){
    localStorage.setItem('miss1',"display:block;")
}else if(!document.querySelector("[value=miss]").checked){
if(document.querySelector("[value=status_mode_new_line]").checked){
    localStorage.setItem('miss1',"visibility:hidden;display:block;")
}else{
    localStorage.setItem('miss1',"display:none;")
}
}if(document.querySelector("[value=acc]").checked && document.querySelector("[value=miss]").checked){
if(document.querySelector("[value=status_mode_new_line]").checked){
    localStorage.setItem('acc1',".acc{display:block;font-size:110%;}")
}else{
    localStorage.setItem('acc1',".acc{display:block;line-height:0;margin-bottom:15.5px;font-size:95%;font-weight:normal;}")
}
}else if(document.querySelector("[value=acc]").checked && !document.querySelector("[value=miss]").checked){
    localStorage.setItem('acc1',".acc{display:block;font-size:110%;}")
}else if(!document.querySelector("[value=acc]").checked){
if(document.querySelector("[value=status_mode_new_line]").checked){
    localStorage.setItem('acc1',".acc{visibility:hidden;display:block;}")
}else{
    localStorage.setItem('acc1',".acc{display:none;}")
}
}if(document.querySelector("[value=combo_counter]").checked){
    localStorage.setItem('combo_counter1',"display:block;")
}else{
if(document.querySelector("[value=status_mode_new_line]").checked){
    localStorage.setItem('combo_counter1',"visibility:hidden;display:block;")
}else{
    localStorage.setItem('combo_counter1',"display:none;")
}
}if(document.querySelector("[value=type_counter]").checked){
    localStorage.setItem('type_counter1',"display:inline-block;")
if(!document.querySelector("[value=escape_counter]").checked){
    localStorage.setItem('type_counter1',"display:block;")
}
}else{
if(document.querySelector("[value=status_mode_new_line]").checked){
    localStorage.setItem('type_counter1',"visibility:hidden;display:block;")
}else{
    localStorage.setItem('type_counter1',"display:none;")
}
}if(document.querySelector("[value=clear_counter]").checked){
    localStorage.setItem('clear_counter1',"display:inline-block;")
if(!document.querySelector("[value=line_count]").checked){
    localStorage.setItem('clear_counter1',"display:block;")
}
}else{
    localStorage.setItem('clear_counter1',"display:none;")
}if(document.querySelector("[value=escape_counter]").checked){
if(document.querySelector("[value=status_mode_new_line]").checked){
    localStorage.setItem('escape_counter1',"display:block;")
}else{
    localStorage.setItem('escape_counter1',"display:inline;")
}
}else{
if(document.querySelector("[value=status_mode_new_line]").checked){
    localStorage.setItem('escape_counter1',"visibility:hidden;display:block;")
}else{
    localStorage.setItem('escape_counter1',"display:none;")
}
}if(document.querySelector("[value=line_count]").checked){
if(document.querySelector("[value=status_mode_new_line]").checked){
    localStorage.setItem('line_count1',"display:block;")
}else{
    localStorage.setItem('line_count1',"display:inline;")
}
}else{
if(document.querySelector("[value=status_mode_new_line]").checked){
    localStorage.setItem('line_count1',"visibility:hidden;display:block;")
}else{
    localStorage.setItem('line_count1',"display:none;")
}
}if(document.querySelector("[value=rank]").checked){
    localStorage.setItem('rank',"display:inline-block;")
}else{
if(document.querySelector("[value=status_mode_new_line]").checked){
    localStorage.setItem('rank',"visibility:hidden;")
}else{
    localStorage.setItem('rank',"display:none;")
}
}if(document.querySelector("[value=typing_speed]").checked){
if(document.querySelector("[value=status_mode_new_line]").checked){
    localStorage.setItem('typing_speed',"display:block;")
}else{
    localStorage.setItem('typing_speed',"display:inline;")
}
}else{
if(document.querySelector("[value=status_mode_new_line]").checked){
    localStorage.setItem('typing_speed',"visibility:hidden;display:block;")
}else{
    localStorage.setItem('typing_speed',"display:none;")
}
}


//設定を反映
checkbox_effect()
checkbox_effect_mod_open_play()
checkbox_effect_play()

//カラーコードの状態保存
OnColorChanged()
//チェックボックス設定保存 判別(サーバーに保存する機能ができ次第削除)ここまで
if(!finished){
difficulty_ave=((difficulty_average/line_length)*Number(document.getElementById("speed").innerHTML)).toFixed(2)
difficulty_ave_kana=((difficulty_average_kana/line_length)*Number(document.getElementById("speed").innerHTML)).toFixed(2)
difficulty_kana=(difficulty_max_kana*Number(document.getElementById("speed").innerHTML)).toFixed(2)
difficulty=(difficulty_max*Number(document.getElementById("speed").innerHTML)).toFixed(2)
if(document.querySelector("[name=mode_select]:checked").value == "kanamode_type"||document.querySelector("[name=mode_select]:checked").value == "kanamode_mac_type"){

if(localStorage.getItem('word_disable') == "true" && (localStorage.getItem('space_disable') == "true" || localStorage.getItem('kigou_disable') == "true") ){
document.querySelector("#difficult > span").innerHTML = '<span title="打鍵数"><i class="fas fa-drum" style="backgroundcolor=:#441188; border-radius: 16px;"></i> '+total_notes_kana_mode + '打</span> <span title="ライン数"><i class="fas fa-scroll" style=""></i>'+line_length+'ライン</span> <span title="長さ"><i class="far fa-clock" style=""></i>'+movie_mm+':'+movie_ss+'</span> <span title="必要入力スピード"><i class="fas fa-tachometer-alt" style=""></i>平均'+difficulty_ave_kana+'打/秒, 最高'+difficulty_kana+'打/秒</span> <span title="省略設定詳細">(省略文字数:'+abridgement_word_length+', 最大点数:'+(((kana_score_per_char * (total_notes_kana_mode-kana_daku_handaku_length))/20)/100).toFixed(2)+'</span>';
}else{
document.querySelector("#difficult > span").innerHTML = '<span title="打鍵数"><i class="fas fa-drum" style="backgroundcolor=:#441188; border-radius: 16px;"></i> '+total_notes_kana_mode + '打</span> <span title="ライン数"><i class="fas fa-scroll" style=""></i>'+line_length+'ライン</span> <span title="長さ"><i class="far fa-clock" style=""></i>'+movie_mm+':'+movie_ss+'</span> <span title="必要入力スピード"><i class="fas fa-tachometer-alt" style=""></i>平均'+difficulty_ave_kana+'打/秒, 最高'+difficulty_kana+'打/秒</span>';
}

}else{
if(localStorage.getItem('word_disable') == "true" && (localStorage.getItem('space_disable') == "true" || localStorage.getItem('kigou_disable') == "true") ){
document.querySelector("#difficult > span").innerHTML = '<span title="打鍵数"><i class="fas fa-drum" style="backgroundcolor=:#441188; border-radius: 16px;"></i> '+total_notes + '打</span> <span title="ライン数"><i class="fas fa-scroll" style=""></i>'+line_length+'ライン</span> <span title="長さ"><i class="far fa-clock" style=""></i>'+movie_mm+':'+movie_ss+'</span> <span title="必要入力スピード"><i class="fas fa-tachometer-alt" style=""></i>平均'+difficulty_ave+'打/秒, 最高'+difficulty+'打/秒</span> <span title="省略設定詳細">(省略文字数:'+abridgement_word_length+', 最大点数:'+(((roma_score_per_char * total_notes)/20)/100).toFixed(2)+')</span>';
}else{
document.querySelector("#difficult > span").innerHTML = '<span title="打鍵数"><i class="fas fa-drum" style="backgroundcolor=:#441188; border-radius: 16px;"></i> '+total_notes + '打</span> <span title="ライン数"><i class="fas fa-scroll" style=""></i>'+line_length+'ライン</span> <span title="長さ"><i class="far fa-clock" style=""></i>'+movie_mm+':'+movie_ss+'</span> <span title="必要入力スピード"><i class="fas fa-tachometer-alt" style=""></i>平均'+difficulty_ave+'打/秒, 最高'+difficulty+'打/秒</span>';
}
}

}

}



//カラーコードをlocalstorageに保存
function OnColorChanged(selectedColor, input) {
    localStorage.setItem('miss_color', document.querySelector("[name=miss_color]").value)
    localStorage.setItem('countdown_color', document.querySelector("[name=countdown_color]").value)
    localStorage.setItem('skipguide_color', document.querySelector("[name=skipguide_color]").value)
    localStorage.setItem('combo_color', document.querySelector("[name=combo_color]").value)
    localStorage.setItem('first_color1', document.querySelector("[name=first_color]").value)
    localStorage.setItem('playarea_color', document.querySelector("[name=playarea_color]").value)
    localStorage.setItem('futidori_color', document.querySelector("[name=futidori_color]").value)
    localStorage.setItem('correctword_color', document.querySelector("[name=correctword_color]").value)
    localStorage.setItem('lineclear_color', document.querySelector("[name=lineclear_color]").value)
    localStorage.setItem('word_color', document.querySelector("[name=word_color]").value)
    localStorage.setItem('lyric_color', document.querySelector("[name=lyric_color]").value)
    localStorage.setItem('next_lyrics_color', document.querySelector("[name=next_lyrics_color]").value)
    localStorage.setItem('line_color', document.querySelector("[name=line_color]").value)
    localStorage.setItem('line_color2', document.querySelector("[name=line_color2]").value)
    localStorage.setItem('line_empty_color', document.querySelector("[name=line_empty_color]").value)
    localStorage.setItem('line_empty_color2', document.querySelector("[name=line_empty_color2]").value)
    localStorage.setItem('status_color', document.querySelector("[name=status_color]").value)
    localStorage.setItem('me_color', document.querySelector("[name=me_color]").value)
    localStorage.setItem('control_color', document.querySelector("[name=control_color]").value)

    //設定を反映
    document.getElementById("controlbox").style.backgroundColor=document.querySelector("[name=playarea_color]").value;
    document.getElementById("controlbox").style.borderRadius=document.querySelector("[name=playarea_radius]").value+"px";
    document.getElementById("controlbox").style.border=document.querySelector("[name=futidori_theme]").value;
    document.getElementById("controlbox").style.borderColor=document.querySelector("[name=futidori_color]").value;
    document.getElementById("controlbox").style.borderWidth=document.querySelector("[name=futidori_border-width]").value;
    document.getElementById("controlbox").style.paddingBottom="6px";
if(window.navigator.userAgent.indexOf('Firefox') != -1) {
    document.getElementById("line_color_styles").innerHTML = "#bar_input_base::-moz-progress-bar{background-color:"+document.querySelector("[name=line_color]").value+
        "!important;}#bar_input_base{background-color:"+document.querySelector("[name=line_empty_color]").value+"!important;}"+
        "#bar_base::-moz-progress-bar{background-color:"+document.querySelector("[name=line_color2]").value+"!important;}#bar_base{background-color:"+document.querySelector("[name=line_empty_color2]").value+"!important;}"+
        "#controlbox .text-teal {color:"+document.querySelector("[name=me_color]").value+"!important;}#controlbox .col-4,#controlbox .col-4 a,#controlbox .col-4 .h4,#line_remaining_time,#total_time{color:"+document.querySelector("[name=status_color]").value+
        "!important;}#controlbox .control {color:"+document.querySelector("[name=control_color]").value+"!important;}}";
}else{
    document.getElementById("line_color_styles").innerHTML = "#bar_input_base::-webkit-progress-value{background-color:"+document.querySelector("[name=line_color]").value+
        "!important;}#bar_input_base[value]::-webkit-progress-bar{background-color:"+document.querySelector("[name=line_empty_color]").value+"!important;}"+
        "#bar_base::-webkit-progress-value{background-color:"+document.querySelector("[name=line_color2]").value+"!important;}#bar_base[value]::-webkit-progress-bar{background-color:"+document.querySelector("[name=line_empty_color2]").value+"!important;}"+
        "#controlbox .text-teal {color:"+document.querySelector("[name=me_color]").value+"!important;}#controlbox .col-4,#controlbox .col-4 a,#controlbox .col-4 .h4,#line_remaining_time,#total_time{color:"+document.querySelector("[name=status_color]").value+
        "!important;}#controlbox .control {color:"+document.querySelector("[name=control_color]").value+"!important;}}";
}
if(!is_played){
    document.getElementById("esckey").style.color=document.querySelector("[name=status_color]").value;
  for(let i=0;i<document.getElementsByClassName("playButton").length;i++){
    document.getElementsByClassName("playButton")[i].style.color = document.querySelector("[name=status_color]").value;}
}else if(is_played && !finished){
    document.getElementById("kashi").style.color=document.querySelector("[name=lyric_color]").value;
    document.getElementById("kashi_next").style.color=document.querySelector("[name=next_lyrics_color]").value;
    document.getElementById("next_kpm").style.color=document.querySelector("[name=next_lyrics_color]").value;
    updateLineView();
if(document.querySelector("[value=combo_display]").checked){
if(combo>=1 && next_char[0]){
    document.getElementById("combo_stat2").innerHTML = "<div style='color:"+document.querySelector("[name=combo_color]").value+";' class='combo_anime combo_animated'>"+combo+"</div>";
}
else if(combo==0 && typing_count>=1){
    document.getElementById("combo_stat2").innerHTML = "<div style='color:"+document.querySelector("[name=combo_color]").value+";'>"+0+"</div>";
}
}
}
}


//スクロール調整値設定をlocalstorageに保存
function scroll_change(){
    localStorage.setItem('scroll_adjustment1',document.querySelector("[name=scroll_adjustment1]").value)

if(is_played&&!finished){
window.scrollTo({top:(document.documentElement.scrollTop+document.getElementById("controlbox").getBoundingClientRect().top+document.getElementById("controlbox").clientHeight+Number(localStorage.getItem('scroll_adjustment1'))-document.documentElement.clientHeight)})
}
}


//タイピングワードのフォントサイズ設定を反映
function set_status_setting(){
if(mode!="roma"&&mode!="kana"){return}
var kashi_roma_name="";
var kashi_sub_name="";
if(mode=="roma"){
  kashi_roma_name="roma";
  kashi_sub_name="kana";
}
if(mode=="kana"){
  kashi_roma_name="kana";
  kashi_sub_name="roma";
}
document.getElementById("status_setting").innerHTML= ".score{"+localStorage.getItem('score1')+"}.miss{"+localStorage.getItem('miss1')+"}"+localStorage.getItem('acc1')+".combo_counter{"+localStorage.getItem('combo_counter1')+"}.type_counter{"+localStorage.getItem('type_counter1')+"}.clear_counter{"+localStorage.getItem('clear_counter1')+"}.escape_counter{"+localStorage.getItem('escape_counter1')+"}.line_count{"+localStorage.getItem('line_count1')+"}.rank{"+localStorage.getItem('rank')+"}.typing_speed{"+localStorage.getItem('typing_speed')+"}#kashi_roma{font-size:"+document.querySelector("[name=font_size_"+kashi_roma_name+"]").value+"px;}#kashi_sub{font-size:"+document.querySelector("[name=font_size_"+kashi_sub_name+"]").value+"px;}";
}




//プレイ中に必要な設定を反映(プレイ開始時に1度読み込まれる)
function checkbox_effect_play(){
if(is_played && !finished){

if(document.querySelector("[value=not_video]").checked&&document.querySelector("[value=play_scroll]").checked){
    document.getElementById("player").classList.add('kashi_hidden')
}else{
    document.getElementById("player").classList.remove('kashi_hidden')
}

if(document.querySelector("[value=line_hidden]").checked){
    document.getElementById("kashi_next").classList.add('kashi_hidden')
    document.getElementById("next_kpm").classList.add('kashi_hidden')

}else{
    document.getElementById("kashi_next").classList.remove('kashi_hidden')
    document.getElementById("next_kpm").classList.remove('kashi_hidden')
}

if(document.querySelector("[value=status_mode_new_line]").checked){
    document.querySelector("#controlbox .col-8").style.flex="0 0 100%";
    document.querySelector("#controlbox .col-8").style.maxWidth="100%";
    document.querySelector("#controlbox .col-4").style.flex="0 0 100%";
    document.querySelector("#controlbox .col-4").style.maxWidth="100%";
}else{
    document.querySelector("#controlbox .col-8").style.flex="0 0 75.66667%";
    document.querySelector("#controlbox .col-8").style.maxWidth="75.66667%";
    document.querySelector("#controlbox .col-4").style.flex="0 0 24.33333%";
    document.querySelector("#controlbox .col-4").style.maxWidth="24.33333%";
}


if(!document.querySelector("[value=combo_display]").checked){
    document.getElementById("combo_stat2").textContent = "";
}

if(document.querySelector("[value=letter_scroll]").checked){
    document.getElementById("kashi_roma").classList.add('letter_scroll')
    document.getElementById("kashi_sub").classList.add('letter_scroll','sub_margin')
    document.getElementById("kashi_roma").classList.remove('mt-2')
    document.getElementById("kashi_sub").classList.remove('mt-2')
}else{
    document.getElementById("kashi_roma").classList.remove('letter_scroll')
    document.getElementById("kashi_sub").classList.remove('letter_scroll','sub_margin')
    document.getElementById("kashi_roma").classList.add('mt-2')
    document.getElementById("kashi_sub").classList.add('mt-2')
}

if(!kana_mode){
if(document.querySelector("[value=sub]").checked){
    document.getElementById("kashi_sub").classList.remove('kashi_hidden')
}else{
    document.getElementById("kashi_sub").classList.add('kashi_hidden')
}

if(mode == 'roma'){
        document.getElementById("kashi_roma").classList.add('roma_input_dom')
        document.getElementById("kashi_sub").classList.add('kana_input_dom')
if(!document.querySelector("[value=oomoji_shift]").checked){
    document.getElementById("kashi_sub").style.textTransform="lowercase";
}else{
    document.getElementById("kashi_sub").style.textTransform="";
}
}else if(mode == 'kana'){
    document.getElementById("kashi_roma").classList.add('kana_input_dom')
    document.getElementById("kashi_sub").classList.add('roma_input_dom')
if(!document.querySelector("[value=oomoji_shift]").checked){
    document.getElementById("kashi_sub").style.textTransform="uppercase";
    document.getElementById("kashi_roma").style.textTransform="lowercase";
}else{
    document.getElementById("kashi_sub").style.textTransform="";
    document.getElementById("kashi_roma").style.textTransform="";
}
}
    document.getElementById("kashi_roma").classList.add('letter_space')
    document.getElementById("kashi_sub").classList.add('letter_space')
}else{
if(!document.querySelector("[value=oomoji_shift]").checked){
    document.getElementById("kashi_roma").style.textTransform="lowercase";
}else{
    document.getElementById("kashi_roma").style.textTransform="";
}
}
if(count > 0){
if(document.querySelector("[value=next_text_reading]").checked&&lyrics_array[count+1][1]!='end'){
    document.getElementById("kashi_next").innerHTML = '<ruby>&#8203;<rt>&#8203;</rt></ruby>&nbsp;'+typing_array_kana[count].join('');
}else{
    document.getElementById("kashi_next").innerHTML = '<ruby>&#8203;<rt>&#8203;</rt></ruby>&nbsp;'+lyrics_array[count][1];
}
}
    set_status_setting();
    update_status();
}

}







/*
*@MOD設定保存・反映 ここまで---
**/
/////////////////////////////////////////////////////////////////////////////////////////////////









////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
*@プレイ中の処理 全体  ここから---
*/



//打鍵周り計算
//correct
//ミス制限モード判定
//miss数カウント

let correct = 100 //正確率

let keep_corrent = "" //目標性格率と現在性格率の差
let life_corrent = "" //残りライフ(ライフ制)
//打鍵共通して呼ばれる処理
function keystroke_update(){
if(typing_count) {
    correct = typing_count / (typing_miss_count + typing_count) * 100.0
}

if(!finished){
if(document.querySelector("[value=perfect_mode]").checked){
//document.querySelector("[name=miss_limit]").valueは目標正確率
    keep_corrent="["+(correct-document.querySelector("[name=miss_limit]").value).toFixed(1)+"%]"

if(document.querySelector("[value=keep_corrent]").checked){//正確率維持

//statusの表示方法(ライフは表示しない)
if(document.querySelector("[value=status_mode_not_break]").checked){
    life_corrent = ""
}
else{
    life_corrent = typing_miss_count
}

if(correct < document.querySelector("[name=miss_limit]").value){//correctが目標製確率より下がったらゲームオーバー
    gameover()
if(stop_time_flag){createjs.Ticker.removeEventListener("tick", time_calculation);}
    gameover_sound.play()
    keep_corrent_color="#FF4B00"
}

}else{//ライフ制
if(document.querySelector("[value=status_mode_not_break]").checked){
    life_corrent = "["+(total_notes-escape_word_length - (total_notes-escape_word_length) * document.querySelector("[name=miss_limit]").value/100-typing_miss_count).toFixed(1)+"]life"
}else{
    life_corrent =(total_notes-escape_word_length - (total_notes-escape_word_length) * document.querySelector("[name=miss_limit]").value/100-typing_miss_count).toFixed(1)
}

if( (total_notes-escape_word_length - (total_notes-escape_word_length) * document.querySelector("[name=miss_limit]").value/100-typing_miss_count) < 0 ){//ライフが0未満でゲームオーバー
    gameover()
if(stop_time_flag){createjs.Ticker.removeEventListener("tick", time_calculation);}
    gameover_sound.play()
    life_corrent_color="#FF4B00"
}
}

}else{//ミス制限モードオフ
    keep_corrent = ""
if(document.querySelector("[value=status_mode_not_break]").checked){
    life_corrent = ""
}else if(document.querySelector("[value=status_mode_new_line]").checked){
    life_corrent = typing_miss_count
}

if(!stop_time_flag){
    time_calculation()
}else{
    typing_speed_calculation()
}
}

}
}




//正解打鍵処理
function add_typing_count(){
typing_count++;
combo++;
if(max_combo < combo){max_combo = combo;}
miss_combo = 0;
if(score > 199999){score = 200000}

//ランキングのスコアを抜かした時の処理
if( (score/20)/100 >= ranking_array[0]){//次の目標スコアを超えた時

for(let i = 0; i < ranking_length; i++){//現在の自分のスコアより下のスコアを削除
        ranking_array.shift();
if( (score/20)/100 < ranking_array[0] || ranking_array.length == 0){//目標スコアが自分のスコアより高くなったらループ終わり
if(document.querySelector("[value=status_mode_not_break]").checked){
    document.getElementsByClassName("rank")[0].innerHTML = (ranking_array.length +1) + "<span style='font-weight:normal;'>位</span>"
}else{
    document.querySelector(".rank .score_text2").innerHTML = (ranking_array.length +1) + "<span style='font-weight:normal;'>位</span>"
}
    break;
}
}

}

if(next_char[0].length == 0) { //ラインクリア時の打鍵タイム加算
if(stop_time_flag) {
    practice_time_current += ((new Date).getTime()-stop_time)/1000
    stop_time_flag = false
    paractice_speed_time = -0.1
    createjs.Ticker.removeEventListener("tick", time_calculation);
    player.playVideo();
}
    keystroke_update()
    past_playing_time += line_playing_time
    completed = true;

}else{
//該当するstatusを更新
keystroke_update()
}
if(document.querySelector("[value=status_mode_not_break]").checked){
    document.getElementsByClassName("score")[0].textContent = ((score/20)/100).toFixed(2)
    document.getElementsByClassName("combo_counter")[0].textContent = combo+"combo"
    document.getElementById("type_counter_text").textContent = typing_count
    document.getElementById("corrent_text").textContent = (correct.toFixed(1))+"%"+keep_corrent
}else{
    document.querySelector(".score .score_text").textContent = ((score/20)/100).toFixed(2)
    document.querySelector(".combo_counter .status_text").textContent = combo
    document.querySelector(".type_counter .status_text2").textContent = typing_count
    document.getElementsByClassName("acc")[0].textContent = keep_corrent
    document.querySelector(".acc .status_text2").textContent = correct.toFixed(1)+"%"
}


}


//打鍵効果音
//コンボエフェクト

let combo100 = false; //100コンボ以上ならtrue

function type_effect(){

if(document.querySelector("[value=combo_display]").checked){
if(combo>=1 && document.querySelector("[value=combo_animation]").checked){
    document.getElementById("combo_stat2").innerHTML = "<div style='color:"+document.querySelector("[name=combo_color]").value+";' class='combo_animated'id='combo_anime'>"+combo+"</div>";
}else if(combo>=1 && !document.querySelector("[value=combo_animation]").checked){
    document.getElementById("combo_stat2").innerHTML = "<div style='color:"+document.querySelector("[name=combo_color]").value+";'>"+combo+"</div>";
}
}

if (document.querySelector("[value=type_sound]").checked && !completed) {key_type_play()}

if(combo >= 100){combo100 = true;}

}


//タイピングワードのみ更新
//正解打鍵をした時更新
function updateLineView_typing() {
if(kana_mode){
    document.getElementsByClassName("first_color")[0].textContent = next_char[0]

if(document.querySelector("[value=letter_scroll]").checked){
    document.querySelector(".correct_input").textContent = already_input.replace(/ /g,"⎽").substr(-localStorage.getItem('letter_scroll_kana'),localStorage.getItem('letter_scroll_kana'))
}else{
    document.querySelector(".correct_input").innerHTML = already_input.replace(/</g, '&lt;').replace(/ /g, "<span class=underline> </span>" )
}
if(document.querySelector("[value=eng_highlight]").checked && /[^!-~]/.test(next_char[0]) == false && ((/.*[ぁ-ん|ヴ|ゔ|ー|、|。|゛]$/.test(already_input)||already_input=='') && (/^[ぁ-ん|ヴ|ゔ|ー|、|。|゛].*/.test(line_input_kana[0]) || line_input_kana[0] == undefined)) == false){
    document.getElementsByClassName("first_color")[0].style.textDecoration = "underline"
    document.getElementsByClassName("first_color")[1].style.textDecoration = "underline"

    document.querySelectorAll(".first_color")[1].textContent = line_input_kana.join('').substr(0,(line_input_kana.join('')+" ").search(/[^!-~]/))
    document.querySelector(".typing_word").textContent = (line_input_kana.join('')+" ").slice(line_input_kana.join('').search(/[^!-~]/))
}else{
    document.getElementsByClassName("first_color")[0].style.textDecoration = ""
    document.getElementsByClassName("first_color")[1].style.textDecoration = ""

    document.querySelector(".typing_word").textContent = line_input_kana.join('')
}
//ローマ字モードの表示(ローマ・かな表示両方)
}else if(!kana_mode){
let roma_first_letter = ""
let roma_words = ""

if(next_char.length > 1){
    roma_words = next_char[1].slice(1) + line_input_roma.join('')
if(document.querySelector("[value=oomoji_shift]").checked && /[A-ZA-Z]/.test(next_char[0])){
    roma_first_letter= next_char[1][0].toUpperCase()
}else{
    roma_first_letter= next_char[1][0]
}
}

    document.querySelector(".kana_input_dom .first_color").textContent = (next_char[0][0] || [])
    document.querySelector(".roma_input_dom .first_color").textContent = roma_first_letter

if(document.querySelector("[value=letter_scroll]").checked){
    document.querySelector(".kana_input_dom .correct_input").textContent = already_input.replace(/ /g, "⎽").substr(-localStorage.getItem('letter_scroll_kana'),localStorage.getItem('letter_scroll_kana'))
    document.querySelector(".roma_input_dom .correct_input").textContent = already_input_roma.replace(/ /g, "⎽").substr(-localStorage.getItem('letter_scroll_roma'),localStorage.getItem('letter_scroll_roma'))
}else{
    document.querySelector(".kana_input_dom .correct_input").innerHTML = already_input.replace(/</g, '&lt;').replace(/ /g, "<span class=underline> </span>" )
    document.querySelector(".roma_input_dom .correct_input").innerHTML = already_input_roma.replace(/</g, '&lt;').replace(/ /g, "<span class=underline> </span>" )
}
    document.querySelector(".roma_input_dom .typing_word").textContent = roma_words

//英単語をハイライトするモード
if(document.querySelector("[value=eng_highlight]").checked && /[^!-~]/.test(next_char[0]) == false && ((/.*[ぁ-ん|ヴ|ゔ|ー|、|。|゛]$/.test(already_input)||already_input=='') && (/^[ぁ-ん|ヴ|ゔ|ー|、|。|゛].*/.test(line_input_kana[0]) || line_input_kana[0] == undefined)) == false){
    document.querySelector(".kana_input_dom .first_color").style.textDecoration = "underline"
    document.querySelectorAll(".kana_input_dom .first_color")[1].style.textDecoration = "underline"

    document.querySelectorAll(".kana_input_dom .first_color")[1].textContent = line_input_kana.join('').substr(0,(line_input_kana.join('')+" ").search(/[^!-~]/))
    document.querySelector(".kana_input_dom .typing_word").textContent = (line_input_kana.join('')+" ").slice(line_input_kana.join('').search(/[^!-~]/))

}else{
    document.querySelector(".kana_input_dom .first_color").style.textDecoration = ""
    document.querySelectorAll(".kana_input_dom .first_color")[1].style.textDecoration = ""
    document.querySelector(".kana_input_dom .typing_word").textContent = line_input_kana.join('')
    document.querySelectorAll(".kana_input_dom .first_color")[1].textContent = (next_char[0].slice(1) || [])
}
}
}




///////////////////////////////////////////////////////////////////////



//ミスタイピング処理
function add_typing_miss_count(){
typing_miss_count ++;
combo=0;
miss_combo++;
if(score>0){score-=score_per_char/4}
if(score<0){score=0}

//該当するstatusを更新

keystroke_update()
if(finished) { return; }
if(document.querySelector("[value=status_mode_not_break]").checked){
    document.getElementsByClassName("score")[0].textContent = ((score/20)/100).toFixed(2)
    document.getElementById("life_corrent_text").textContent = life_corrent
    document.getElementById("miss_text").textContent = typing_miss_count
    document.getElementsByClassName("combo_counter")[0].textContent = combo+"combo"
    document.getElementById("corrent_text").textContent = (correct.toFixed(1))+"%"+keep_corrent
}else{
    document.querySelector(".score .score_text").textContent = ((score/20)/100).toFixed(2)
    document.querySelector(".miss .status_text").textContent = life_corrent
    document.querySelector(".combo_counter .status_text").textContent = combo
    document.getElementsByClassName("acc")[0].textContent = keep_corrent
    document.querySelector(".acc .status_text2").textContent = correct.toFixed(1)+"%"
}

}


//ミス効果音
//ミスマーク表示
//コンボエフェクトリセット
var missmark = document.createElement("span");
    missmark.setAttribute("style", "position: absolute;top: -.49em;margin: auto;font-size: 1.4em;");
    missmark.setAttribute("id", "missmark");
    missmark.textContent="・"

function miss_effect(){
if(document.querySelector("[value=combo_display]").checked && miss_combo == 1){
    document.getElementById("combo_stat2").innerHTML="<div style='color:"+document.querySelector("[name=combo_color]").value+";'>"+0+"</div>";
}

if(miss_combo && (!kana_mode && already_input_roma.length != 0 || kana_mode && already_input.length != 0) || document.querySelector("[value=miss_sound_top]").checked){

if(!combo100){
if(document.querySelector("[value=miss_sound]").checked){
    miss_type_play()
}

}else{//100combo

if(document.querySelector("[value=combo_break_sound]").checked && miss_combo){
    combo_break.play();//100 combo以上でミスするとcombo break音
}else if(document.querySelector("[value=miss_sound]").checked){
    miss_type_play()
}
    combo100 = false;//フラグOFF
}

}


    if(document.querySelector("[value=miss_on]").checked && next_char[0] != "" && document.getElementById("missmark") == null){//ミス表示を追加
        missmark.style.left = (document.getElementsByClassName("first_color")[0].getBoundingClientRect().width-24.2)/2+"px"
if(!kana_mode && already_input_roma.length == 0 || kana_mode && already_input.length == 0){
    missmark.style.color = document.querySelector("[name=word_color]").value
}else{
    missmark.style.color = document.querySelector("[name=miss_color]").value
}
        document.getElementsByClassName("first_color")[0].appendChild(missmark)
}
}



///////////////////////////////////////////////////////////////////////




///////////////////////////////////////////////////////////////////////

//ラインクリア処理
function line_completed(){
    complete_count ++;
    next_point = 0;

//クリア時は現在のライン経過時間を加算

for(let i=0;i<document.querySelectorAll(".correct_input").length;i++){
    document.querySelectorAll(".correct_input")[i].style.color = document.querySelector("[name=lineclear_color]").value
}
//該当するstatusを更新
if(document.querySelector("[value=status_mode_not_break]").checked){
    document.getElementsByClassName("clear_counter")[0].innerHTML = complete_count + "<span style='font-size:90%;'>clear</span>"
    document.getElementsByClassName("line_count")[0].innerHTML = "["+(line_length-(failer_count+complete_count))+"]<span style='font-size:90%;'>line</span><br>"
}else{
    document.querySelector(".clear_counter .line_text2").textContent = complete_count
    document.querySelector(".line_count .line_text").textContent = line_length-(failer_count+complete_count)
}

line_clear_effect()
}



let clear_percent=0 //ラインクリア率
let clear_gauge1=0 //ラインクリアゲージ伸び率(80%未満)
let clear_gauge2=0 //ラインクリアゲージ伸び率(80%以上)
let clear_linecounter=0 //80%以上の伸び率計算に使用
let game_clear = false //80%以上クリアフラッグ

//クリアゲージエフェクト
function line_clear_effect(){
if(document.querySelector("[value=gauge]").checked && line_remaining_time > 0.6){
document.getElementById("complete_effect").classList.add('countdown_animation','complete_animated')
document.getElementById("complete_effect").innerHTML = "<div style='color:"+document.querySelector("[name=combo_color]").value+";'>Complete!!</div>"

}
if(document.querySelector("[value=clear_sound]").checked){
    clear_type_play()
}else if(!document.querySelector("[value=clear_sound]").checked && document.querySelector("[value=type_sound]").checked){
    key_type_play()
}

    clear_percent=(complete_count / line_length) * 100.0;
if( ((score/20)/100) < 50){
    document.getElementById("clear_percent").textContent = clear_percent.toFixed(0)+"%";
}else if( ((score/20)/100) >= 50 && clear_percent < 80){
    document.getElementById("clear_percent").innerHTML = clear_percent.toFixed(0)+"%<i style='width: 0px;display: contents!important;color:#FFF;' class='fa fa-trophy'></i>";
}else if(clear_percent >= 80 && clear_percent != 100){
    document.getElementById("clear_percent").innerHTML = clear_percent.toFixed(0)+"%<i style='width: 0px;display: contents!important;color:#8B4513;' class='fa fa-trophy'></i>";
}else if(clear_percent == 100 && ((score/20)/100) < 99.99){
    document.getElementById("clear_percent").innerHTML = clear_percent.toFixed(0)+"%<i style='width: 0px;display: contents!important;color:#C0C0C0;' class='fa fa-trophy'></i>";
}else if( ((score/20)/100) >= 99.99){
    document.getElementById("clear_percent").innerHTML = clear_percent.toFixed(0)+"%<i style='width: 0px;display: contents!important;color:#FFD700;' class='fa fa-trophy'></i>";
}

    clear_gauge1=(complete_count / line_length) * 200.0
if(!game_clear){
    document.getElementById("clear_gauge").style.width=(clear_gauge1/1.6)+"%";
    document.getElementById("clear_gauge").style.backgroundColor="#fff";
}
if(game_clear){
    clear_gauge2=(clear_gauge2+1)
    document.getElementById("clear_gauge2").style.width=((clear_gauge2/clear_linecounter)*100)+"%";
}
if(!game_clear&& clear_percent>=80){
    clear_linecounter=line_length*(100-clear_percent)/100
    clear_gauge2=(clear_percent-80)/10
    game_clear=true
    document.getElementById("clear_gauge").style.width="100%";
    document.getElementById("clear_percent").style.color="#FFEB3B";
    document.getElementById("clear_gauge2").style.backgroundColor="#FFEB3B";
    document.getElementById("clear_gauge2").style.width=(((clear_gauge2/clear_linecounter)*100)+1)+"%";
    document.querySelector("#gauge2 > span").style.cssText = "";
}

}



///////////////////////////////////////////////////////////////////////


//タイピング時のショートカットキー
function arrowkey(){
if(event.shiftKey && event.key == "ArrowUp"){
    skip = 2;
    update_skip();
    event.preventDefault();
} else if(event.shiftKey && event.key == "ArrowDown"){
    skip = false;
    update_skip();
    event.preventDefault();
} else if(event.key == "ArrowDown") {
    volume = player.getVolume();
    volume = volume - 10;
    if(volume < 0) {volume = 0;}
    player.setVolume(volume);
    localStorage.setItem('volume_storage', volume);
    document.getElementById("volume").textContent = volume
    event.preventDefault();
} else if(event.key == "ArrowUp"){
    volume = player.getVolume();
    volume = volume + 10;
    if(volume > 100) {volume = 100;}
    player.setVolume(volume);
    localStorage.setItem('volume_storage', volume);
    document.getElementById("volume").textContent = volume
    event.preventDefault();
} else if(event.key == "ArrowLeft" && !event.altKey) {
var difftime = player.difftime;
    difftime = difftime - 0.1;
    if(difftime < -4.0) {difftime = -4.0;}
    player.difftime = difftime;
    document.getElementById("time_diff").textContent = difftime.toFixed(2);
    event.preventDefault();
} else if(event.key == "ArrowRight" && !event.altKey){
var difftime = player.difftime;
    difftime = difftime + 0.1;
    if(difftime > 4.0) {difftime = 4.0;}
    player.difftime = difftime;
    document.getElementById("time_diff").textContent = difftime.toFixed(2);
    event.preventDefault();
}else if(event.key=="F10") {//F10で倍速
    speedup();
    event.preventDefault();
}else if(event.code=="Space" && document.getElementById("skip_guide").textContent == "Type Space key to skip. ⏩" || event.key=="Enter" && document.getElementById("skip_guide").textContent == "Type Enter key to skip. ⏩"){
    player.seekTo(parseFloat(lyrics_array[count][0]) + player.difftime - 1);
    seeked_count = count;
    stop_count = 0;
    document.getElementById("skip_guide").textContent = "";
    playheadUpdate();
}else if(event.key=="Escape"){//Escでポーズ
    player.pauseVideo()
    event.preventDefault();

}

if(event.key == "ArrowLeft" && event.altKey) {
    return;
}else if(event.key=="Tab" || event.key=="F3" || event.altKey || event.code=="Space" || event.code=="Backspace" || window.navigator.userAgent.indexOf('Firefox') != -1 && (event.key=="'" || event.key=="/")) {
    event.returnValue = false;
    event.preventDefault();
}

}

//打鍵パターンを最適化するMOD設定
function keystroke_pattern_optimisation(){
//ひらがな2文字の周りくどい入力方法ltuta,xtufu,silya,ltuteleなどを入力できなくする機能
if(document.querySelector("[value=mizumasi]").checked){
if(next_char[0].length >= 2 && /^(?!(っゃ|っゅ|っょ|っぁ|っぃ|っぅ|っぇ|っぉ|っっ|っゎ|っヵ|っヶ))[ぁ-ん]/.test(next_char[0])) {
    next_char=next_char.filter(function(value) { return value.match(/^(?!.*(x|l)).*$/)})
}
}
}


///////////////////////////////////////////////////////////////////////






/////////////////////////////////////////////////////////////////////////////////////////////////
/**
*@ローマ入力判定 ここから---
*/



keydownfunc = function (event) {
if(document.activeElement.tagName == "INPUT"){return;}
         if(next_char.length > 1 &&
            (event.keyCode >= 65 && event.keyCode <= 90 ||//A-Z
            event.code=="Space" ||//スペース
event.key === '!'||event.key === '"'||event.key === '#'||event.key === '$'||event.key === '%'||event.key === '&'||event.key === "'"||event.key === '('||event.key === ')'||event.key === '='||event.key === '~'||event.key === '\|'//SHIFT最上段
||(event.key >=0 && event.key <=9) || event.key === '-' ||event.key === '^'||event.key === '\\'//最上段
||event.key === '@'||event.key === '`'||event.key === '['||event.key === '{'//上段
||event.key === '+'||event.key === '*'||event.key === ':'||event.key === ';'||event.key === ']'||event.key === '}'//中段
||event.key === '\_'||event.key === '/'||event.key === '?'||event.key === '.'||event.key === ','||event.key === '<'||event.key === '>'))//下段
{
             var c = (event.key).toLowerCase();


              if(c != "" && checkNextChar(c)){
                  updateLineView_typing()
                  add_typing_count();
                  type_effect();
if(!practice_failure){
if(document.querySelector("[value=oomoji_shift]").checked && event.shiftKey){
                typinglog.push([player.getCurrentTime().toFixed(3), c.toUpperCase(), score.toFixed(), count, completed ? 1 : 0, 1]);
}else{
                typinglog.push([player.getCurrentTime().toFixed(3), c, score.toFixed(), count, completed ? 1 : 0, 1]);
}
}

              } else if(!completed) {
                  if(already_input_roma.length != 0) {
                      add_typing_miss_count();
if(!practice_failure){
    if(document.querySelector("[value=oomoji_shift]").checked && event.shiftKey){
        typinglog.push([player.getCurrentTime().toFixed(3), c.toUpperCase(), score.toFixed(), count, completed ? 1 : 0, 0]);
    }else{
        typinglog.push([player.getCurrentTime().toFixed(3), c, score.toFixed(), count, completed ? 1 : 0, 0]);
    }
}
                  }
                  if(finished) { return; }
                  miss_effect();
              }
}
        arrowkey();
          return false;
      }

checkNextChar=function (c){

    flag = false;
    flag_roma = false;
    next_char_slice = next_char.slice(1)
const next_char_typing_length = next_char_slice.length

for (let i=0; i<next_char_typing_length; i++){
//ncは打鍵パターンが入る
//c==nc[0][0](先頭の文字が一致したときに正解の処理がされる)
          if(c == next_char_slice[i][0]){


if(document.querySelector("[value=oomoji_shift]").checked){
if ( !event.shiftKey && /[A-ZA-Z]/.test(next_char[0]) || event.shiftKey && /[a-za-z]/.test(next_char[0]) ){
    break;
}}
//xnで「ん」を入力する場合は[nn]のパターンを削除
if(next_char[0]=='ん'&& c=='x' && line_input_roma[0] && line_input_roma[0][0]!='n'){
    line_input[0] = line_input[0].filter(function(value) { return value.match(/^(?!(n)).*$/)})
}


if(!flag && next_char_slice[i].length >= 2){

//ひらがなを1文字ずつ処理する
if(next_char[0].length >= 2){
if(next_char[0][0] != 'っ' && (next_char_slice[i][1][0] == 'x' || next_char_slice[i][1][0] == 'l') || //拗音
   next_char[0][0] == 'っ' &&
   (c == 'u' || //「っ」のみ入力
next_char_slice[i][1][0] == c && (next_char_slice[i][0][0] != 'x' && next_char_slice[i][0][0] != 'l') //tta等の促音の1打鍵目
// already_input_roma[already_input_roma.length-1] == c || // っぁ[xxa]等
)) {
    already_input = already_input + next_char[0][0]
    next_char[0] = next_char[0].slice(1);
}
}

//以下打鍵パターンを絞る処理
if(next_char.length > 2 && (c != 'n' || next_char_slice[i] == 'nn')){
    flag = true;

//打鍵パターンを絞る正規表現
    regexp_c = new RegExp('^('+c+').*$')
    next_char=[next_char[0]].concat(next_char.slice(1).filter(function(value) { return value.match(regexp_c)}))

//打鍵パターンを絞ったnext_charを再度eachで回す
    next_char_slice=next_char.slice(1)
for (let j=0; j<next_char_slice.length; j++){
          if(c==next_char_slice[j][0][0]){
              next_char[j+1] = next_char_slice[j].slice(1);
          }
if(flag_roma == false) {
    already_input_roma = already_input_roma + c;
    flag_roma = true;
}
}
//最後に打鍵数が少ない順にソート
    next_char=[next_char[0]].concat(next_char.slice(1).sort(function(a, b) {return a.length - b.length;}))
break;
}
}

//以下から通常の処理
next_char[i+1] = next_char_slice[i].slice(1);
flag = true;

            if(flag_roma == false) {
if(document.querySelector("[value=oomoji_shift]").checked && /[A-ZA-Z]/.test(next_char[0]) ){
              already_input_roma = already_input_roma + c.toUpperCase();
   }else{
              already_input_roma = already_input_roma + c;
   }
              flag_roma = true;

            }
            if(next_char_slice[i].length == 1) {
              already_input = already_input + next_char[0]; //正解した場合、クリアかな文に文字を追加
              next_char = line_input.shift(1) || []; //next_charに次の文字の打鍵パターンを追加
              line_input_roma.shift(1); //ローマ字文はcで加えているので、ただ先頭を削除
              next_char.unshift(line_input_kana.shift(1) || []);//next_charの先頭にかな文字を追加
              score+=next_point;
          if(next_char[0].length == 0) {
                line_completed()
          } else {
                next_point = next_char[1].length * score_per_char;
                keystroke_pattern_optimisation()
          }
break;
            }


}
        };
        return flag;
      }



/*
*@ローマ字入力判定 ここまで---
**/
/////////////////////////////////////////////////////////////////////////////////////////////////





/////////////////////////////////////////////////////////////////////////////////////////////////
/**
*@かな入力判定 ここから---
*/



//keypressfunc_kana = function (event) {}

keydownfunc_kana=function (event) {
if(document.activeElement.tagName == "INPUT"){return;}
         if(next_char[0] != "" &&
            (event.keyCode >= 65 && event.keyCode <= 90 ||//A-Z
            event.code=="Space" ||//スペース
event.key === '!'||event.key === '"'||event.key === '#'||event.key === '$'||event.key === '%'||event.key === '&'||event.key === "'"||event.key === '('||event.key === ')'||event.key === '='||event.key === '~'||event.key === '\|'//SHIFT最上段
||(event.key >=0 && event.key <=9) || event.key === '-' ||event.key === '^'||event.key === '\\'//最上段
||event.key === '@'||event.key === '`'||event.key === '['||event.key === '{'//上段
||event.key === '+'||event.key === '*'||event.key === ':'||event.key === ';'||event.key === ']'||event.key === '}'//中段
||event.key === '\_'||event.key === '/'||event.key === '?'||event.key === '.'||event.key === ','||event.key === '<'||event.key === '>'))//下段
{         var c = [];
            daku = false;
            daku_kana_list = ["ゔ","が","ぎ","ぐ","げ","ご","ざ","じ","ず","ぜ","ぞ","だ","ぢ","づ","で","ど","ば","び","ぶ","べ","ぼ"];
            handaku = false;
            handaku_kana_list = ["ぱ","ぴ","ぷ","ぺ","ぽ"];

             kana_keymap = {
               0: function() { return ["わ","0"] },
               1: function() { return ["ぬ","1"] },
              "!": function() { return["ぬ","!"] },
               2: function() { return ["ふ", "ぶ", "ぷ","2"] },
               3: function() { return ["あ","3"] },
               4: function() { return ["う", "ゔ","4"] },
               5: function() { return ["え","5"] },
               6: function() { return ["お","6"] },
               7: function() { return ["や","7"] },
               8: function() { return ["ゆ","8"] },
               9: function() { return ["よ","9"] },
              "-": function() { return ["ほ", "ぼ", "ぽ"] },
              "q": function() { return ["た", "だ","q"] },
              "Q": function() { return ["た", "だ","q"] },
              "w": function() { return ["て", "で","w"] },
              "W": function() { return ["て", "で","w"] },
              "e": function() { return ["い","e"] },
              "r": function() { return ["す", "ず","r"] },
              "R": function() { return ["す", "ず","r"] },
              "t": function() { return ["か", "が","t"] },
              "T": function() { return ["か", "が","t"] },
              "y": function() { return ["ん","y"] },
              "Y": function() { return ["ん","y"] },
              "u": function() { return ["な","u"] },
              "U": function() { return ["な","u"] },
              "i": function() { return ["に","i"] },
              "I": function() { return ["に","i"] },
              "o": function() { return ["ら","o"] },
              "O": function() { return ["ら","o"] },
              "p": function() { return ["せ", "ぜ","p"] },
              "P": function() { return ["せ", "ぜ","p"] },
              "a": function() { return ["ち", "ぢ","a"] },
              "A": function() { return ["ち", "ぢ","a"] },
              "s": function() { return ["と", "ど","s"] },
              "S": function() { return ["と", "ど","s"] },
              "d": function() { return ["し", "じ","d"] },
              "D": function() { return ["し", "じ","d"] },
              "f": function() { return ["は", "ば", "ぱ","f"] },
              "F": function() { return ["は", "ば", "ぱ","f"] },
              "g": function() { return ["き", "ぎ","g"] },
              "G": function() { return ["き", "ぎ","g"] },
              "h": function() { return ["く", "ぐ","h"] },
              "H": function() { return ["く", "ぐ","h"] },
              "j": function() { return ["ま","j"] },
              "J": function() { return ["ま","j"] },
              "k": function() { return ["の","k"] },
              "K": function() { return ["の","k"] },
              "l": function() { return ["り","l"] },
              "L": function() { return ["り","l"] },
              "z": function() { return ["つ", "づ","z"] },
              "x": function() { return ["さ", "ざ","x"] },
              "X": function() { return ["さ", "ざ","x"] },
              "c": function() { return ["そ", "ぞ","c"] },
              "C": function() { return ["そ", "ぞ","c"] },
              "v": function() { return ["ひ", "び", "ぴ","v"] },
              "V": function() { return ["ひ", "び", "ぴ","v"] },
              "b": function() { return ["こ", "ご","b"] },
              "B": function() { return ["こ", "ご","b"] },
              "n": function() { return ["み","n"] },
              "N": function() { return ["み","n"] },
              "m": function() { return ["も","m"] },
              "M": function() { return ["も","m"] },
              ",": function() { return ["ね"] },
              "<": function() { return ["、","<"] },
              ".": function() { return ["る"] },
              ">": function() { return ["。",">"] },
              "/": function() { return ["め"] },
              "?": function() { return ["・","?"] },
              "#": function() { return ["ぁ","#"] },
              "$": function() { return ["ぅ","$"] },
              "%": function() { return ["ぇ","%"] },
              "E": function() { return ["ぃ","e"] },
              "Z": function() { return ["っ","z"] }
          }
/*恐らくus版のmacキーボード
         if(keyboard == 'mac') {
             mac_keymap = {
              94: function() { return ["ぉ","^"] },
              38: function() { return ["ゃ", "&"] },
              42: function() { return ["ゅ", "*"] },
              40: function() { return ["ょ", "("] },
              41: function() { return ["を", ")"] },
              95: function() { return ["_", "ほ", "ぼ", "ぽ"] },
              45: function() { return ["-", "ほ", "ぼ", "ぽ"] },
              61: function() { return ["=", "へ", "べ", "ぺ"] },
              43: function() { return ["+", "へ", "べ", "ぺ"] },
              59: function() { return [";", "れ"] },
              58: function() { return [":", "れ"] },
              39: function() { return ["'", "け", "げ"] },
              34: function() { return ["け", "げ"] },
              92: function() { return "む" },
              165: function() { return "-", "ー" },
              124: function() { return "|" },
              91: function() { return ["[", "゛"] },
              123: function() { return ["{", "゛"] },
              125: function() { return ["}", "「"] },
              93: function() { return ["]", "゜"] },
              64: function() { return ["ふ", "@", "ぶ", "ぷ"] },
              126: function() { return ["-", "~"] },
             }
}
*/
             windows_keymap = {
              "'": function() { return ["ゃ","’"] },
              "^": function() { return ["へ", "べ", "ぺ","^"] },
              "~": function() { return ["へ", "べ", "ぺ","~"] },
              "&": function() { return ["ぉ","&"] },
              "(": function() { return ["ゅ","("] },
              ")": function() { return ["ょ",")"] },
              'IntlYen': function() { return ["ー","¥"] },
              '|': function() { return ["ー","|"] },
              "IntlRo": function() { return ["ろ","¥"] },
              "_": function() { return ["ろ","_"] },
              "=": function() { return ["ほ", "ぼ", "ぽ","="] },
              "+": function() { return ["れ","+"] },
              ";": function() { return ["れ",";"] },
              '"': function() { return ["ふ", "ぶ", "ぷ","”"] },
              "@": function() { return ["゛","@"] },
              "[": function() { return ["゜","「"] },
              ']': function() { return ["む","」"] },
              ":": function() { return ["け", "げ",";"] },
              "*": function() { return ["け", "げ","*"] }
             }
/*mac_keymapは恐らくus配列の表なので、一時的に無効化
            if(navigator.userAgent.match(/Mac|PPC/)) {
              kana_keymap = $.extend(kana_keymap, mac_keymap);
            } else {
              kana_keymap = $.extend(kana_keymap, windows_keymap);
            }
*/

              kana_keymap = $.extend(kana_keymap, windows_keymap);

            if(kana_keymap[event.key]) {
              c = kana_keymap[event.key]();
              if([].indexOf.call(daku_kana_list, next_char[0]) > -1) {
                daku = true;
              } else if ([].indexOf.call(handaku_kana_list, next_char[0]) > -1) {
                handaku = true;
              }
            }else if(windows_keymap[event.code]) {
              c = windows_keymap[event.code]();
}
  if(event.shiftKey && event.key == 0){
              c = ["を"];
            }
/*
else if(navigator.userAgent.match(/Mac|PPC/)) {mac_keymapは恐らくus配列の表なので、一時的に無効化
            if(event.key == "-") {
              c = ["ー", "ろ"];
            }
*/

c.push(event.key.toLowerCase())

              if(c != "" && c != undefined && checkNextKana(c, daku, handaku)){
                  updateLineView_typing()
                  add_typing_count();
                  type_effect();
if(!practice_failure){
if(daku || handaku) {
                typinglog.push([player.getCurrentTime().toFixed(3), c[0], score.toFixed(), count, completed ? 1 : 0, 1]);
}else{
if(document.querySelector("[value=oomoji_shift]").checked && event.shiftKey){
                typinglog.push([player.getCurrentTime().toFixed(3), c[kana_key_objects].toUpperCase(), score.toFixed(), count, completed ? 1 : 0, 1]);
}else{
                typinglog.push([player.getCurrentTime().toFixed(3), c[kana_key_objects], score.toFixed(), count, completed ? 1 : 0, 1]);
}
}
}
              } else if(!completed) {
                  if(already_input.length != 0) {
                  add_typing_miss_count();
if(!practice_failure){
    typinglog.push([player.getCurrentTime().toFixed(3), c[0], score.toFixed(), count, completed ? 1 : 0, 0]);
}
                  }
if(finished) { return; }
miss_effect();
              }
}
       arrowkey();
       return false;
     }

var kana_key_objects = 0;
checkNextKana = function (c, daku, handaku){

kana_key_objects = [].indexOf.call(c, next_char[0].toLowerCase())

        if(kana_key_objects > -1) {
if(document.querySelector("[value=oomoji_shift]").checked){
if (/[A-ZA-Z]/.test(next_char[0]) && !event.shiftKey||(/[a-za-z]/.test(next_char[0]) && event.shiftKey) ){
return false;
}
}
          if(daku) {
            next_char = ["゛", next_char[0]];
            return true;
          } else if (handaku) {
            next_char = ["゜", next_char[0]];
            return true;
          }

          if([].indexOf.call(["゛", "゜"], next_char[0]) > -1) {
            already_input = already_input + next_char[1];
          } else {
            already_input = already_input + next_char[0];
          }

if(line_input_kana.length > 0 && line_input_kana[0].length > 1){
    next_char = line_input_kana[0].slice( 0, 1 );//next_charの先頭にかな文字を追加
    line_input_kana[0] = line_input_kana[0].slice(1)//next_charに追加した文字を削除
}else{
    line_input.shift();
    already_input_roma += line_input_roma.shift(1)
    next_char = (line_input_kana.shift(1) || [[]]);
}
            score += next_point;
          if(next_char[0].length == 0) {
                line_completed()
          } else {
            next_point = score_per_char;
          }
          return true;
        }
        return false;
      }



/*
*@かな入力判定 ここまで---
**/
/////////////////////////////////////////////////////////////////////////////////////////////////





/////////////////////////////////////////////////////////////////////////////////////////////////
/**
*@動画スピード変更 ここから---
*/



var difficulty_ave=0
var difficulty_ave_kana=0
var difficulty_kana=0
var difficulty=0
function time_conversion(){
movieTotalTime = document.getElementById("bar_base").getAttribute('max')/speed
movie_mm =("00" + parseInt(parseInt(movieTotalTime) / 60)).slice(-2)
movie_ss = ("00" +(parseInt(movieTotalTime) - movie_mm * 60)).slice(-2)
difficulty_ave=((difficulty_average/line_length)*speed).toFixed(2)
difficulty_ave_kana=((difficulty_average_kana/line_length)*speed).toFixed(2)
difficulty_kana=(difficulty_max_kana*speed).toFixed(2)
difficulty=(difficulty_max*speed).toFixed(2)
//かな入力モード
if(document.querySelector("[name=mode_select]:checked").value == "kanamode_type"||document.querySelector("[name=mode_select]:checked").value == "kanamode_mac_type"){

if(localStorage.getItem('word_disable') == "true" && (localStorage.getItem('space_disable') == "true" || localStorage.getItem('kigou_disable') == "true") ){
document.querySelector("#difficult > span").innerHTML = '<span title="打鍵数"><i class="fas fa-drum" style="backgroundcolor=:#441188; border-radius: 16px;"></i> '+total_notes_kana_mode + '打</span> <span title="ライン数"><i class="fas fa-scroll" style=""></i>'+line_length+'ライン</span> <span title="長さ"><i class="far fa-clock" style=""></i>'+movie_mm+':'+movie_ss+'</span> <span title="必要入力スピード"><i class="fas fa-tachometer-alt" style=""></i>平均'+difficulty_ave_kana+'打/秒, 最高'+difficulty_kana+'打/秒</span> <span title="省略設定詳細">(省略文字数:'+abridgement_word_length+', 最大点数:'+(((kana_score_per_char * (total_notes_kana_mode-kana_daku_handaku_length))/20)/100).toFixed(2)+'</span>';
}else{
document.querySelector("#difficult > span").innerHTML = '<span title="打鍵数"><i class="fas fa-drum" style="backgroundcolor=:#441188; border-radius: 16px;"></i> '+total_notes_kana_mode + '打</span> <span title="ライン数"><i class="fas fa-scroll" style=""></i>'+line_length+'ライン</span> <span title="長さ"><i class="far fa-clock" style=""></i>'+movie_mm+':'+movie_ss+'</span> <span title="必要入力スピード"><i class="fas fa-tachometer-alt" style=""></i>平均'+difficulty_ave_kana+'打/秒, 最高'+difficulty_kana+'打/秒</span>';
}

}else{
if(localStorage.getItem('word_disable') == "true" && (localStorage.getItem('space_disable') == "true" || localStorage.getItem('kigou_disable') == "true") ){
document.querySelector("#difficult > span").innerHTML = '<span title="打鍵数"><i class="fas fa-drum" style="backgroundcolor=:#441188; border-radius: 16px;"></i> '+total_notes + '打</span> <span title="ライン数"><i class="fas fa-scroll" style=""></i>'+line_length+'ライン</span> <span title="長さ"><i class="far fa-clock" style=""></i>'+movie_mm+':'+movie_ss+'</span> <span title="必要入力スピード"><i class="fas fa-tachometer-alt" style=""></i>平均'+difficulty_ave+'打/秒, 最高'+difficulty+'打/秒</span> <span title="省略設定詳細">(省略文字数:'+abridgement_word_length+', 最大点数:'+(((roma_score_per_char * total_notes)/20)/100).toFixed(2)+')</span>';
}else{
document.querySelector("#difficult > span").innerHTML = '<span title="打鍵数"><i class="fas fa-drum" style="backgroundcolor=:#441188; border-radius: 16px;"></i> '+total_notes + '打</span> <span title="ライン数"><i class="fas fa-scroll" style=""></i>'+line_length+'ライン</span> <span title="長さ"><i class="far fa-clock" style=""></i>'+movie_mm+':'+movie_ss+'</span> <span title="必要入力スピード"><i class="fas fa-tachometer-alt" style=""></i>平均'+difficulty_ave+'打/秒, 最高'+difficulty+'打/秒</span>';
}
}
if(is_played&&!finished){
next_line_word_check()
    now_time = headtime/speed
time_calculation()
line_time_count = now_time
document.getElementById("total_time").textContent = ("00" + parseInt(parseInt(now_time) / 60)).slice(-2) + ':' + ("00" +(parseInt(now_time) - ("00" + parseInt(parseInt(now_time) / 60)).slice(-2) * 60)).slice(-2) + " / " + movie_mm+':'+movie_ss;
time_count = now_time
}

}


play_speed_up = function () {
       if(count > 0) { return false; }
       speed = player.getPlaybackRate();
       flag = true;
       player.getAvailablePlaybackRates().sort().forEach(function(sp) {
         if(sp > speed && flag) {
           speed = sp;
           flag = false;
         }
       });
       play_speed = speed;
       player.setPlaybackRate(speed);
document.getElementById("playspeed").textContent = speed.toFixed(2)+"倍速"
document.getElementById("speed").textContent = speed.toFixed(2)
document.getElementById("default_speed").textContent = play_speed.toFixed(2)+"倍速"
time_conversion(speed)
     }
play_speed_down = function () {
       if(count > 0) { return false; }
       speed = player.getPlaybackRate();
       flag = true;
       player.getAvailablePlaybackRates().sort().reverse().forEach(function(sp) {
         if(sp < speed && flag) {
           speed = sp;
           flag = false;
         }
       });
       play_speed = speed;
       player.setPlaybackRate(speed);
document.getElementById("playspeed").textContent = speed.toFixed(2)+"倍速"
document.getElementById("speed").textContent = speed.toFixed(2)
document.getElementById("default_speed").textContent = play_speed.toFixed(2)+"倍速"
time_conversion(speed)
     }
speedup = function () {
       speed = player.getPlaybackRate();
       flag = true;
       player.getAvailablePlaybackRates().sort().forEach(function(sp) {
         if(sp > play_speed && sp > speed && flag) {
           speed = sp;
           flag = false;
         }
       });
       if(flag) {
         speed = play_speed;
       }
       player.setPlaybackRate(speed);
document.getElementById("speed").textContent = speed.toFixed(2)
time_conversion(speed)
     }

/*
*@動画スピード変更 ここまで---
**/
/////////////////////////////////////////////////////////////////////////////////////////////////






/////////////////////////////////////////////////////////////////////////////////////////////////
/**
*@playheadUpdate ここから---
*/


let skip_code = ""
function skipguide(){
//スキップ案内を表示
if(!document.querySelector("[value=skip_enter]").checked){skip_code="Space";}else{skip_code="Enter";}

if(!skip && document.querySelector("[value=skip_guide]").checked && document.getElementById("skip_guide").textContent != "Type "+ skip_code +" key to skip. ⏩"){
if(completed && line_remaining_time >= 3.0 || !completed && line_remaining_time >= 3.0 && line_playing_time >= 0.4 && document.getElementById("count_anime").textContent == ""){
document.getElementById("skip_guide").innerHTML = "<span style='color:"+document.querySelector("[name=skipguide_color]").value+";'><i>Type "+ skip_code +" key to skip. ⏩</i></span>";
}
}else if((line_remaining_time <= 3.0 && completed || line_remaining_time <= 1.2 && !completed || document.getElementById("count_anime").textContent != "") && document.getElementById("skip_guide").textContent != ""){
document.getElementById("skip_guide").textContent = "";//(ラインクリア時は3秒)
}


}


let countdown_anime = false//カウントダウンアニメのフラグ
function sec_countdownanime(){


if(document.querySelector("[value=count_animation]").checked){
if(4.0 >= line_remaining_time && line_remaining_time > 3.0 && document.getElementById("count_anime").textContent != "3"){//間奏ラインの残り時間大体3秒ぐらいのとき
document.getElementById("count_anime").innerHTML = "<span style='color:"+document.querySelector("[name=countdown_color]").value+";' class='countdown_animation count_animated'><i>3</i></span>";//残り時間を整数で歌詞エリアに表示
}else if(3.0 >= line_remaining_time && line_remaining_time > 2.0 && document.getElementById("count_anime").textContent != "2"){//間奏ラインの残り時間大体3秒ぐらいのとき
document.getElementById("count_anime").innerHTML = "<span style='color:"+document.querySelector("[name=countdown_color]").value+";'class='countdown_animation count_animated'><i>2</i></span>";//残り時間を整数で歌詞エリアに表示
}else if(2.0 >= line_remaining_time && line_remaining_time > 1.0 && document.getElementById("count_anime").textContent != "1" && document.getElementById("count_anime").textContent != ""){//間奏ラインの残り時間大体3秒ぐらいのとき
document.getElementById("count_anime").innerHTML = "<span style='color:"+document.querySelector("[name=countdown_color]").value+";'class='countdown_animation count_animated'><i>1</i></span>";//残り時間を整数で歌詞エリアに表示
}else if(line_remaining_time <= 1 && document.getElementById("count_anime").textContent != "GO!" && document.getElementById("count_anime").textContent != ""){////間奏ラインの残り時間大体1秒ぐらいのとき
document.getElementById("count_anime").innerHTML = "<span style='color:"+document.querySelector("[name=countdown_color]").value+";'class='countdown_animation count_animated'><i>GO!</i></span>";//歌詞エリアにGO!と表示する
}
}else{
if(4.0 >= line_remaining_time && line_remaining_time > 3.0 && document.getElementById("count_anime").textContent != "3"){//間奏ラインの残り時間大体3秒ぐらいのとき
document.getElementById("count_anime").innerHTML = "<span style='color:"+document.querySelector("[name=countdown_color]").value+";'><i>3</i></span>";//残り時間を整数で歌詞エリアに表示
}else if(3.0 >= line_remaining_time && line_remaining_time > 2.0 && document.getElementById("count_anime").textContent != "2"){//間奏ラインの残り時間大体3秒ぐらいのとき
document.getElementById("count_anime").innerHTML = "<span style='color:"+document.querySelector("[name=countdown_color]").value+";'><i>2</i></span>";//残り時間を整数で歌詞エリアに表示
}else if(2.0 >= line_remaining_time && line_remaining_time > 1.0 && document.getElementById("count_anime").textContent != "1" && document.getElementById("count_anime").textContent != ""){//間奏ラインの残り時間大体3秒ぐらいのとき
document.getElementById("count_anime").innerHTML = "<span style='color:"+document.querySelector("[name=countdown_color]").value+";'><i>1</i></span>"//残り時間を整数で歌詞エリアに表示
}else if(line_remaining_time <= 1 && document.getElementById("count_anime").textContent != "GO!" && document.getElementById("count_anime").textContent != ""){////間奏ラインの残り時間大体1秒ぐらいのとき
document.getElementById("count_anime").innerHTML = "<span style='color:"+document.querySelector("[name=countdown_color]").value+";'><i>GO!</i></span>";//歌詞エリアにGO!と表示する
}
}

}


///////////////////////////////////
//練習モード

let stop_time=0 //止まった時間
let stop_time_flag=false //止まったフラグ
let practice_time = 0 //ライン練習タイム
let practice_time_current = 0 //蓄積ラインタイム
let paractice_speed_time = -0.1 //打鍵速度更新頻度フラグ

///////////////////////////////////


let latency = 0; //反応するまでにかかった時間
let line_playing_time = 0;//ライン経過時間
let past_playing_time = 0;//(過去の入力時間合計)
let line_remaining_time = 0;//ライン残り時間
let playing_time_current = 0;//入力時間(ライン経過時間 + 過去の入力時間合計)



function time_calculation(){
line_remaining_time =Math.abs((lyrics_array[count][0] - headtime)/speed); //ライン残り時間

if(count && !completed){
if(stop_time_flag){practice_time=(((new Date).getTime()-stop_time)/1000)+practice_time_current}

line_playing_time = (headtime - lyrics_array[count - 1][0])/speed+practice_time //経過ライン時間(裏ステータス)
playing_time_current = line_playing_time + past_playing_time //タイピングワードが存在していた累計時間(裏ステータス)

}

if(next_char[0]){

if(already_input_roma.length == 0 && kana_mode == false || already_input.length == 0){
latency = line_playing_time
}

//打鍵速度計算
if(!stop_time_flag){
typing_speed_calculation()
}else if(practice_time - paractice_speed_time >= 0.1 ){
typing_speed_calculation()
if(document.querySelector("[value=line_hidden]").checked){
document.getElementById("remaining_time").textContent = "latency:" + latency.toFixed(3) + "ms"
}
paractice_speed_time = practice_time
}


}else{//ワードが存在しない場合のlatency
latency = 0
line_typingspeed = 0
line_typingspeed_rkpm = 0
}


if(document.querySelector("[value=line_hidden]").checked){
if(!stop_time_flag){
document.getElementById("remaining_time").textContent = "latency:" + latency.toFixed(3) + "ms"
}
}else{
document.getElementById("remaining_time").textContent = "残り" + line_remaining_time.toFixed(1) + "秒"
}

}







let speed_marker= "" //平均より、速ければ▲。遅ければ▼。


let typing_speed = 0; //累計打鍵速度
let line_typingspeed = 0; //ラインの打鍵速度
let line_typingspeed_rkpm = 0; //初速を無視したライン打鍵速度


function typing_speed_calculation(){
line_typingspeed = (typing_count-typing_count_save) / line_playing_time
if(typing_count-typing_count_save == 0){
line_typingspeed_rkpm = (typing_count-typing_count_save) / line_playing_time
}else{
line_typingspeed_rkpm = (typing_count-typing_count_save) / (line_playing_time-latency)
}
typing_speed = typing_count/playing_time_current
if(line_playing_time <=1 && !completed || count > 1 && !lyrics_array[count-1][2] || line_typingspeed == typing_speed){
speed_marker=""
}else if(typing_speed>line_typingspeed || (typing_speed>line_typingspeed&&completed)){
speed_marker="▼"
}else if(typing_speed<line_typingspeed || (typing_speed<line_typingspeed&&completed)){
speed_marker="▲"
}
//DOMに打鍵時間を表示

document.getElementById("type_speed").textContent = typing_speed.toFixed(2);
document.getElementById("line_speed").textContent = line_typingspeed.toFixed(2) + "打/秒" + speed_marker;

}


let time_count = 0
let line_time_count = 0



var headtime = 0;
var now_time = 0;
//playheadUpdateの時間処理
function time_update(){

if(countdown_anime){sec_countdownanime()}


if(document.querySelector("[value=line_hidden]").checked){
document.getElementById("bar_input_base").setAttribute('value', 0);
}else if(count){
document.getElementById("bar_input_base").setAttribute('value',headtime - lyrics_array[count-1][0]); //ラインバー蓄積
}
document.getElementById("bar_base").setAttribute('value', headtime); //累計時間バー蓄積



if(now_time - line_time_count >= 0.1 ){//ライン経過時間 & 打鍵速度計算
time_calculation()
line_time_count = now_time
}
if(now_time - time_count >= 1 ){//曲の経過時間を[分:秒]で表示}
document.getElementById("total_time").textContent = ("00" + parseInt(parseInt(now_time) / 60)).slice(-2) + ':' + ("00" +(parseInt(now_time) - ("00" + parseInt(parseInt(now_time) / 60)).slice(-2) * 60)).slice(-2) + " / " + movie_mm+':'+movie_ss;
time_count = now_time
}
}



playheadUpdate = function () {
    headtime = player.getCurrentTime() + player.difftime;
    now_time = headtime/speed

//ワードが存在しないなら残り1秒にスキップ
        if(seeked_count != count && next_char[0] == "" && lyrics_array[count][0] - headtime > skip){
skipguide()
          if(skip != false) {
            player.seekTo(parseFloat(lyrics_array[count][0]) + player.difftime - skip);
            seeked_count = count;
            stop_count = 0;
            playheadUpdate();
          }
        }

//練習モードでラインクリアするまで止める
        if(play_mode == 'practice' && next_char[0] && !completed && lyrics_array[count][0] - 0.5 <= headtime) {
            if(player.getPlayerState() == 1) {
if(!stop_time_flag){
stop_time=(new Date).getTime()
stop_time_flag=true
}
createjs.Ticker.addEventListener("tick", time_calculation);
practice_mode_rule();
             player.pauseVideo();
            }
            return;
        }

//headtimeを使って時間計算
            time_update()



        if(lyrics_array[count][0] <= headtime){


          if(lyrics_array[count][1] == "end") {
gameover()
return;
          }

document.getElementById("bar_input_base").setAttribute('max', lyrics_array[count+1][0] - lyrics_array[count][0]);


            line_result_check()
          if(finished) {return;}
            next_kashi_check()
            clearForNextString();

document.getElementById("kashi").innerHTML = '<ruby>&nbsp;<rt>&nbsp;</rt></ruby>'+lyrics_array[count][1];
if(document.querySelector("[value=next_text_reading]").checked&&lyrics_array[count+1][1]!='end'){
document.getElementById("kashi_next").innerHTML = '<ruby>&nbsp;<rt>&nbsp;</rt></ruby>'+typing_array_kana[count+1].join('');
}else{
document.getElementById("kashi_next").innerHTML = '<ruby>&nbsp;<rt>&nbsp;</rt></ruby>'+lyrics_array[count+1][1];
}
          if(lyrics_array[count].length == 3) {
              add_line_typingword()
            if(line_input.length > 0) {

            if(!kana_mode) {
              next_char = line_input.shift(1);
              next_char.unshift(line_input_kana.shift(1));
              line_input_roma.shift(1);
                keystroke_pattern_optimisation()
              next_point = next_char[1].length * score_per_char;

            }else if(kana_mode) {
if(line_input_kana.length > 0 && line_input_kana[0].length > 1){
    next_char.unshift(line_input_kana[0].slice( 0, 1 ));//next_charの先頭にかな文字を追加
    line_input_kana[0] = line_input_kana[0].slice(1)//next_charに追加した文字を削除
}else{
    next_char = line_input.shift(1);
    next_char.unshift(line_input_kana.shift(1));
}
                next_point = score_per_char;

            }
            }else{
              next_char = [""];
            }
          } else {
            line_input = [];
            line_input_kana = [];
            line_input_roma = [];
            already_input = "";
            already_input_roma = "";
            next_char = [""];
          }

updateLineView()

          count ++;
          completed=false;
            next_line_word_check()
//スクロール調整処理
            scroll_support()
if(line_length-(failer_count+complete_count) == 0 ){window.setTimeout(typing_result_generator, 150);}

        }
      }


///////////////////////////////
/**ラインアップデート時
*@ライン情報が更新される前の処理
*/

let practice_failure = false //練習モード打ち切り失敗フラグ

//practiceモードで動画停止したら、その時点のresultlogを蓄積
function practice_mode_rule(){
if(!practice_failure){
practice_failure=true
    kpmlog.push(Number((line_typingspeed).toFixed(2)))
    rkpmlog.push(Number((line_typingspeed_rkpm).toFixed(2)))
    line_miss_count_log.push((typing_miss_count-miss_typing_count_save))
if(!kana_mode){
    escape_word_log.push(next_char[1]+line_input_roma.join(''))
}else{
    escape_word_log.push(next_char[0]+line_input_kana.join(''))
}
}

}

///////////////////////////////////
//Typing Resultで使用
//ライン毎の結果を配列に保存

var kpmlog = [] //打鍵速度
var rkpmlog = [] //初速抜き打鍵速度
var latencylog = [] //反応時間
var escape_word_log = [] //逃した文字
var nothing_line_log = [] //タイピングしていないライン情報を保存(typinglogに保存されない為)
var score_penalty_log = [] //そのラインで失ったスコア
var line_miss_count_log = [] //ミス打鍵数

///////////////////////////////////


let total_latency = 0 //latencyの合計値
let typing_line_count = 0 //入力ありラインをカウントする
let typing_count_save = 0; //ライン切替時、現在の打鍵数を取得する
let escape_word_length = 0; //逃した打鍵数
let miss_typing_count_save = 0 //ライン切替時、現在のミス打鍵数を取得する

//var pp=0 //実力ポイント



//現在ラインのタイピングワード情報が捨てられる直前の処理
function line_result_check(){
//実力ポイント計算機能の残骸
//let typing_amount;
//if(line_speed_ranking[0][0] == count-1){
//if(already_input_roma.length>line_speed_ranking[0][1]){
//typing_amount=line_speed_ranking[0][1]
//}else{
//typing_amount=already_input_roma.length
//}
//pp += Number((typing_amount/(lyrics_array[count][0]-lyrics_array[count-1][0])).toFixed(2))
//if(line_speed_ranking.length !=1){
//line_speed_ranking.shift()
//}
//}





if(count >= 1){//2ライン目以降
total_latency += latency
if(next_char[0]){
typing_line_count ++
if(typing_count_save != typing_count){ //入力されているライン
    latencylog.push(Number(latency.toFixed(3)))
}else{
if((typing_count_save+miss_typing_count_save) == (typing_count+typing_miss_count)){ //放置ライン蓄積
nothing_line_log.push([player.getCurrentTime().toFixed(3),"", score.toFixed(), count, 2, 2])

}
    latencylog.push('-')
}

if(!practice_failure){
kpmlog.push(Number(line_typingspeed.toFixed(2)))
rkpmlog.push(Number(line_typingspeed_rkpm.toFixed(2)))
line_miss_count_log.push((typing_miss_count-miss_typing_count_save))
if(!kana_mode){
if(!completed){
    escape_word_log.push(next_char[1]+line_input_roma.join('').replace(/</g, '&lt;'))
}else{
    escape_word_log.push("")
}
}else{
    escape_word_log.push(next_char[0]+line_input_kana.join('').replace(/</g, '&lt;'))
}
}

escape_score_penalty=(next_point+(line_input_roma.join('').length * score_per_char))
miss_score_penalty=((typing_miss_count-miss_typing_count_save)*(score_per_char/4))
score_penalty_log.push(Number((((escape_score_penalty+miss_score_penalty)  /20)/100).toFixed(2)))

//ラインクリア失敗時
if(!completed){
failer_count ++

if(!kana_mode){
escape_word_length += (next_char[1]+line_input_roma.join('')).length
}else if(kana_mode){
escape_word_length += (next_char[0]+line_input_kana.join('')).length
}
//該当するstatusを更新

if(finished) { return; }
keystroke_update()
past_playing_time += (lyrics_array[count - 0][0]-lyrics_array[count - 1][0])/speed+practice_time//ライン時間を加算
if(document.querySelector("[value=status_mode_not_break]").checked){
document.getElementsByClassName("escape_counter")[0].innerHTML = "["+escape_word_length + "]esc<br>"
document.getElementsByClassName("line_count")[0].innerHTML = "["+(line_length-(failer_count+complete_count))+"]<span style='font-size:90%;'>line</span><br>"
document.getElementById("life_corrent_text").textContent = life_corrent
document.getElementById("miss_text").textContent = typing_miss_count
}else{
document.querySelector(".escape_counter .status_text2").textContent = escape_word_length
document.querySelector(".line_count .line_text").textContent = line_length-(failer_count+complete_count)
document.querySelector(".miss .status_text").textContent = life_corrent
}
}

}
else {
//空白ライン
    kpmlog.push(0)
    rkpmlog.push(0)
    escape_word_log.push("")
    line_miss_count_log.push(0)
    latencylog.push("-")
    score_penalty_log.push(0)
nothing_line_log.push([player.getCurrentTime().toFixed(3),"", score.toFixed(), count, 3, 2])

}
practice_time=0
practice_time_current=0
practice_failure=false
miss_typing_count_save = typing_miss_count
typing_count_save = typing_count //現在ラインの打鍵数を出す
if(finished) { return; }

document.getElementById("skip_guide").textContent = "";
document.getElementById("line_speed").textContent = "0.00打/秒"
}

}


function next_kashi_check(){

//歌詞のみ有りで読みがないラインを次の歌詞に表示しない
if(lyrics_array[count+1][1] != 'end' && typing_array_kana[count+1].length == 0){
document.getElementById("kashi_next").classList.add('next_hidden')
}else{
document.getElementById("kashi_next").classList.remove('next_hidden')
}

//英語の改行位置調整
if(typing_array_kana[count].join("").indexOf(" ") < 0){
document.getElementById("kashi_sub").classList.remove('eng_word')
document.getElementById("kashi_roma").classList.remove('eng_word')
document.getElementById("kashi_sub").classList.add('jp_word')
document.getElementById("kashi_roma").classList.add('jp_word')
}else{
document.getElementById("kashi_sub").classList.remove('jp_word')
document.getElementById("kashi_roma").classList.remove('jp_word')
document.getElementById("kashi_sub").classList.add('eng_word')
document.getElementById("kashi_roma").classList.add('eng_word')
}

if(countdown_anime){
countdown_anime = false //カウントダウンフラグOFF
document.getElementById("count_anime").textContent = ""
}
document.getElementById("complete_effect").classList.remove('countdown_animation','count_animated')
document.getElementById("complete_effect").textContent = ""

}


clearForNextString = function () {
        already_input = "";
        already_input_roma = "";
        line_input = [];
        next_char = [];
        window.focus();
      }
/*ラインアップデート時
*@ライン情報が更新される前の処理 ここまで
**/
///////////////////////////////




///////////////////////////////
/**ラインアップデート時
*@ライン情報が更新された直後の処理
*/


function add_line_typingword(){
            line_input = typing_array[count];
            line_input_roma = typing_array_roma[count];
            line_input_kana = typing_array_kana[count];
}


//タイピングワードフィールド全体更新
//ラインアップデート時更新
function updateLineView() {
let kashi_kana_html
let kashi_roma_html

//かな入力モードの表示(かな表示のみ)
if(kana_mode){
if(document.querySelector("[value=letter_scroll]").checked){
    document.getElementById("kashi_roma").innerHTML = "<span style='position: absolute;bottom: 0;'><span class='correct_input' style='color:"+document.querySelector("[name=correctword_color]").value+";'></span><span class='first_color first_letter' style='color:"+document.querySelector("[name=first_color]").value+";position: relative;'></span><span class='first_color' style='color:"+document.querySelector("[name=first_color]").value+";'></span><span class='typing_word' style='color:"+document.querySelector("[name=word_color]").value+";'></span></span>";
}else{
    document.getElementById("kashi_roma").innerHTML = "<span><span class='correct_input' style='color:"+document.querySelector("[name=correctword_color]").value+";'></span><span class='first_color first_letter' style='color:"+document.querySelector("[name=first_color]").value+";position: relative;'></span><span class='first_color' style='color:"+document.querySelector("[name=first_color]").value+";'></span><span class='typing_word' style='color:"+document.querySelector("[name=word_color]").value+";'></span></span>";

}
}else{
//スクロールモード
if(document.querySelector("[value=letter_scroll]").checked){
    kashi_kana_html = "<span style='position: absolute;bottom: 0;'><span class='correct_input' style='color:"+document.querySelector("[name=correctword_color]").value+";'></span><span class='first_color first_letter' style='color:"+document.querySelector("[name=first_color]").value+";position: relative;'></span><span class='first_color' style='color:"+document.querySelector("[name=first_color]").value+";'></span><span class='typing_word' style='color:"+document.querySelector("[name=word_color]").value+";'></span></span>";
    kashi_roma_html = "<span style='position: absolute;bottom: 0;'><span class='correct_input' style='color:"+document.querySelector("[name=correctword_color]").value+";'></span><span class='first_color first_letter' style='color:"+document.querySelector("[name=first_color]").value+";position: relative;'></span><span class='typing_word' style='color:"+document.querySelector("[name=word_color]").value+";'></span></span>";
}else{
    kashi_kana_html = "<span><span class='correct_input' style='color:"+document.querySelector("[name=correctword_color]").value+";'></span><span class='first_color first_letter' style='color:"+document.querySelector("[name=first_color]").value+";position: relative;'></span><span class='first_color' style='color:"+document.querySelector("[name=first_color]").value+";'></span><span class='typing_word' style='color:"+document.querySelector("[name=word_color]").value+";'></span></span>";
    kashi_roma_html = "<span><span class='correct_input' style='color:"+document.querySelector("[name=correctword_color]").value+";'></span><span class='first_color first_letter' style='color:"+document.querySelector("[name=first_color]").value+";position: relative;'></span><span class='typing_word' style='color:"+document.querySelector("[name=word_color]").value+";'></span></span>";
}
    document.getElementsByClassName("roma_input_dom")[0].innerHTML = kashi_roma_html;
    document.getElementsByClassName("kana_input_dom")[0].innerHTML = kashi_kana_html;
}
    updateLineView_typing()

}



let next_kpm = 0;//次のラインの必要kpm

//カウントダウンして良いラインならcountdownフラグON
//次のタイピングワードの必要打鍵速度計算
function next_line_word_check(){
if(typing_array_kana[count] != "" && lyrics_array[count][1] != "end"){
//!next_char[0]はラインクリア時はfalseになる
//よって!next_char[0] == trueはワードが存在しないライン
if(!next_char[0] && document.querySelector("[value=anime_count]").checked){
//現在の#kashiが空白 && 次のラインにワードがある
if(!lyrics_array[count-1][1]){
countdown_anime = true
}
}

//次ラインの打鍵速度を計算して表示
if(!kana_mode){
next_kpm = (typing_array_roma[count].join("").length / (lyrics_array[count+1][0]-lyrics_array[count][0])*speed).toFixed(2)
}else{
next_kpm = (typing_array_kana[count].join('').length+(typing_array_kana[count].join('').match( /[ゔ||が||ぎ||ぐ||げ||ご||ざ||じ||ず||ぜ||ぞ||だ||ぢ||づ||で||ど||ば||び||ぶ||べ"||ぼ||ぱ||ぴ||ぷ||ぺ||ぽ]/g ) || []).length / (lyrics_array[count+1][0]-lyrics_array[count][0])*speed).toFixed(2)
}
document.getElementById("next_kpm").innerHTML = "<span id='kpm_color' style='color:"+document.querySelector("[name=next_lyrics_color]").value+";'>&nbsp;NEXT:<span class='next_kpm_value'>"+next_kpm+"</span>打/秒</span>";
}else{
document.getElementById("next_kpm").innerHTML = "&nbsp;";
}

}


//スクロール調整設定ON時
//歌詞が長すぎてプレイエリアが画面外に出てしまう場合はスクロール調整
function scroll_support(){
if(document.querySelector("[value=play_scroll]").checked&& count>1 &&document.documentElement.scrollTop+document.getElementById("kashi_roma").getBoundingClientRect().top<Number((window.scrollY+document.documentElement.clientHeight).toFixed())){
if(Number(window.scrollY+document.documentElement.clientHeight) < Number(document.documentElement.scrollTop+document.getElementById("controlbox").getBoundingClientRect().top+document.getElementById("controlbox").clientHeight-20) && (document.documentElement.clientHeight-document.getElementsByTagName('header')[0].clientHeight)>parseInt(window.getComputedStyle(document.getElementById("controlbox")).height)-20){
if(Number(localStorage.getItem('scroll_adjustment1'))>=0){
window.scrollTo({
    top: (document.documentElement.scrollTop+document.getElementById("controlbox").getBoundingClientRect().top+document.getElementById("controlbox").clientHeight-document.documentElement.clientHeight-10),
behavior: "smooth",
});
}else{
window.scrollTo({
    top: (document.documentElement.scrollTop+document.getElementById("controlbox").getBoundingClientRect().top+document.getElementById("controlbox").clientHeight+Number(localStorage.getItem('scroll_adjustment1'))-document.documentElement.clientHeight),
behavior: "smooth",
});
}
}else if((document.documentElement.clientHeight-document.getElementsByTagName('header')[0].clientHeight)<parseInt(window.getComputedStyle(document.getElementById("controlbox")).height)){
if(document.getElementById("gauge").style.display == "none"){
window.scrollTo({
    top: document.documentElement.scrollTop+document.getElementById("controlbox").getBoundingClientRect().top-document.getElementsByTagName('header')[0].clientHeight,
behavior: "smooth",
});
}else{
window.scrollTo({
    top: document.documentElement.scrollTop+document.getElementById("player").getBoundingClientRect().top+ document.getElementById("player").clientHeight-document.getElementsByTagName('header')[0].clientHeight,
    behavior: "smooth"
});
}
}else if((!lyrics_array[count-1][2]&&!lyrics_array[count-1][1] ||!lyrics_array[count-2][2]&&lyrics_array[count-1][2])){
if(document.documentElement.scrollTop+document.getElementById("kashi_roma").getBoundingClientRect().top+document.getElementById("kashi_roma").clientHeight>window.scrollY&&control_default_size >= Number(document.documentElement.scrollTop+document.getElementById("controlbox").getBoundingClientRect().top+document.getElementById("controlbox").clientHeight-10)){
window.scrollTo({
    top:document.documentElement.scrollTop+document.getElementById("controlbox").getBoundingClientRect().top+document.getElementById("controlbox").clientHeight+Number(localStorage.getItem('scroll_adjustment1'))-document.documentElement.clientHeight
,
behavior: "smooth",
})
}
}
}

}




/*ラインアップデート時
*@ライン情報が更新された直後の処理 ここまで
**/
///////////////////////////////


/*
*@プレイ中の処理 全体  ここまで---
**/
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////







/////////////////////////////////////////////////////////////////////////////////////////////////
/**
*@プレイ終了時の関数変更 ここから---
*/

//プレイ終了
function gameover(){
not_play_event()
finished = true;
stop_movie();

}



stop_movie = function () {

    player.stopVideo();
    document.getElementById("bar_base").style.display = "none"
    document.getElementById("kashi").style.display = "none"
    document.getElementById("kashi_roma").style.display = "none"
    document.getElementById("kashi_next").style.display = "none"


        if(finished) {
          finish_comment();
        } else {
        $.ajax({
          type: 'GET',
          url:"/ime.txt",
            success:function (data){
              completeIme(data);
            },
            error:function() {
              alert("imeデータの読み込みに失敗しました");
            }
        });
        }
      }

function not_play_event(){
    createjs.Ticker.removeEventListener("tick", playheadUpdate);
        if(kana_mode) {
          window.removeEventListener('keydown',keydownfunc_kana,true);
        } else {
          window.removeEventListener('keydown',keydownfunc,true);
        }
}

finish_movie = function () {
        finish_comment();
      }

let logcount = 0 //typinglogのラインカウント確認
let ending = false; //Typing Result生成フラグ

function typing_result_generator(){

if(!ending){

let rkpm_speed = typing_count / (past_playing_time-total_latency)
let typinglog_save = typinglog.concat(nothing_line_log)
let word_result = ""
let word_result_real = ""
let word_result_out=""
let word_result_real_out=""
let Typing_Result = '';
    number_lyrics = 1
    ending = true
typing_result_status();


typinglog_save.sort(
  function(a,b) {
    // 戻り値が正(a-bの差が正)のとき、aをbの後ろに並べ替え
    // 戻り値が負(a-bの差が負)のとき、aをbの前に並べ替え
    return a[0] - b[0];
  })
var Result_div = document.createElement('div');
    Result_div.setAttribute("id", "typingresult");
    document.getElementById("controlbox").parentNode.insertBefore(Result_div, document.getElementById("controlbox").nextElementSibling);

var result_head_html = document.createElement('h1');
    result_head_html.setAttribute("id", "result_head");
    result_head_html.setAttribute("style", "font-size:20px;background-color: rgba(0,0,0,.33);margin:0px!important;padding-bottom: 5px;");
    result_head_html.textContent = "Typing Result"
document.getElementById("typingresult").appendChild(result_head_html)

var typingloglog_html = document.createElement('div');
    typingloglog_html.setAttribute("id", "typingloglog");
    typingloglog_html.setAttribute("style", "word-break: break-all;overflow: scroll; max-height: 700px;font-size: 120%;background-color: rgba(0,0,0,.33);font-weight: 600;user-select: none !important;-ms-user-select: none !important;-moz-user-select: none !important;-webkit-user-select: none !important;");
document.getElementById("typingresult").appendChild(typingloglog_html)
for(let i = 0; i < typinglog_save.length; i++){//入力した文字の数繰り返す

if(logcount == typinglog_save[i][3]){

if(document.querySelector("[value=word_result]").checked){
if(typinglog_save[i][5] == 1){//正当
if(i > 0 && typinglog_save[i-1][5] == 0 && typinglog_save[i][3] == typinglog_save[i-1][3]){//ミスをしていたら
word_result += ('<span style="color:#FF3554">'+typinglog_save[i][1].replace(' ', '⎽')+'</span>')
}else{//してなかったら
word_result +=('<span style="color:#60d7ff">'+typinglog_save[i][1].replace(' ', '⎽')+'</span>')
}
}

}else if(document.querySelector("[value=word_result_real]").checked){
if(typinglog_save[i][5] == 0){//ミス
word_result_real += ('<span style="color:#FF3554">'+typinglog_save[i][1].replace(' ', '⎽')+'</span>')
}else if(typinglog_save[i][5] == 1){//正当
word_result_real +=('<span style="color:#60d7ff">'+typinglog_save[i][1].replace(' ', '⎽')+'</span>')
}
}

}


if(typinglog_save.length-1 > i && logcount < typinglog_save[i+1][3] || typinglog_save.length-1 == i){//ライン番号取得
logcount = typinglog_save[i][3]+1

if(document.querySelector("[value=word_result]").checked){
if(typinglog_save[i][5] == 0){
word_result_out="<br>"+word_result+'<span style="color:#FF3554">'+escape_word_log[typinglog_save[i][3]-1][0].replace(' ', '⎽')+'</span>'+escape_word_log[typinglog_save[i][3]-1].slice(1)
}else{
word_result_out="<br>"+word_result+escape_word_log[typinglog_save[i][3]-1]
}
}
if(document.querySelector("[value=word_result_real]").checked){
if(typinglog_save[i][5] == 0){
word_result_real_out ="<br>"+word_result_real+'<span style="color:#FF3554">'+escape_word_log[typinglog_save[i][3]-1][0].replace(' ', '⎽')+'</span>'+escape_word_log[typinglog_save[i][3]-1].slice(1)
}else{
word_result_real_out ="<br>"+word_result_real+escape_word_log[typinglog_save[i][3]-1]
}
}
if(typinglog_save[i][4] != 3){//空白ラインは出現させない
if(typinglog_save[i][4] == 1 && !escape_word_log[typinglog_save[i][3]-1]){
Typing_Result += ('<span class="result_lyric">'+number_lyrics+'/'+line_length+' '+lyrics_array[typinglog_save[i][3]-1][2]+'</span><span class="seikou" style="color:#FFFF00;">'+' clear</span><span class=daken_moji>' + word_result_out + word_result_real_out + '</span><br>latency: '+latencylog[typinglog_save[i][3]-1]+', '+'打/秒: ' +kpmlog[typinglog_save[i][3]-1]+ ', 初速抜き: '+rkpmlog[typinglog_save[i][3]-1]+', miss: '+line_miss_count_log[typinglog_save[i][3]-1]+', score-penalty: '+score_penalty_log[typinglog_save[i][3]-1]+'<br><br>')
}else{
Typing_Result += ('<span class="result_lyric">'+number_lyrics+'/'+line_length+' '+lyrics_array[typinglog_save[i][3]-1][2]+'</span><span class="sippai" style="color:#F12FFF;">'+' failure</span><span class=daken_moji>' + word_result_out + word_result_real_out + '</span><br>latency: '+latencylog[typinglog_save[i][3]-1]+', '+'打/秒: ' +kpmlog[typinglog_save[i][3]-1]+ ', 初速抜き: '+rkpmlog[typinglog_save[i][3]-1]+', miss: '+line_miss_count_log[typinglog_save[i][3]-1]+', score-penalty: '+score_penalty_log[typinglog_save[i][3]-1]+'<br><br>')
}
number_lyrics = (number_lyrics+1)
}
word_result = ""
word_result_real=""

}


}

var typing_result_html = document.createElement('span');
typing_result_html.innerHTML=Typing_Result
document.getElementById("typingloglog").appendChild(typing_result_html)
if(!document.querySelector("[value=oomoji_shift]").checked){
const eleList = document.querySelectorAll("#typingloglog .daken_moji")

//全部に共通のclassを追加。
for (let i = 0; i < eleList.length; ++i) {
  eleList[i].classList.add('uppercase');
}
}
var rkpm_result_html = document.createElement('h4');
    rkpm_result_html.setAttribute("style", "font-size:120%;background-color: rgba(0,0,0,.33);margin: 0px!important;padding-bottom: 5px;padding-top: 6px;");
    rkpm_result_html.textContent = "初速抜き 打/秒: "+rkpm_speed.toFixed(2)+"key/sec"
document.getElementById("result_head").parentNode.insertBefore(rkpm_result_html, document.getElementById("result_head").nextElementSibling);

var score_result_html = document.createElement('h6');
    score_result_html.setAttribute("style", "font-size:130%;background-color: rgba(0,0,0,.33);margin:0px!important;padding-bottom: 5px;");
    score_result_html.innerHTML = 'Score Penalty<br>Miss: '+ (-typing_miss_count*(((parseInt(score_per_char)/20)/100)/4)).toFixed(2)+'<br>Esc: '+(( ((score/20)/100) + (typing_miss_count*(((score_per_char/20)/100)/4)))-100).toFixed(2).replace(/^[-]?(\d*|0)(\.01)?$/,'0.00')
document.getElementById("result_head").parentNode.insertBefore(score_result_html, document.getElementById("result_head").nextElementSibling);

var line_result_html = document.createElement('h5');
    line_result_html.setAttribute("id", "line_result");
    line_result_html.setAttribute("style", "background-color: rgba(0,0,0,.33);margin:0px!important;padding-bottom: 5px;");
    line_result_html.innerHTML = '<span style="color:#FFFF00;">'+document.querySelectorAll(".seikou").length+' clear</span> / <span style="color:#FFFF00;"><span style="color:#F12FFF;">'+document.querySelectorAll(".sippai").length+' failure</span>'
document.getElementById("result_head").parentNode.insertBefore(line_result_html, document.getElementById("result_head").nextElementSibling);
//pp *= Math.min(1,kpmlog/1500) * 0.1 + 1;
//pp *= Math.pow(correct/100,3)
//pp *= Math.pow(  (((score/20)/100) + typing_miss_count*(((score_per_char/20)/100)/4)) /100,5)
//console.log(pp.toFixed())
if(document.querySelector("[value=play_scroll]").checked){
if(document.documentElement.scrollTop+document.getElementById("controlbox").getBoundingClientRect().top - document.getElementsByTagName('header')[0].clientHeight >window.scrollY){
window.scrollTo({
    top:document.documentElement.scrollTop+document.getElementById("line_result").getBoundingClientRect().top+parseInt(window.getComputedStyle(document.getElementById("line_result")).height)- document.documentElement.clientHeight,
    behavior: "smooth"
});

}
}
}
}


//プレイリザルトで表示するstatus
function typing_result_status(){

if(document.querySelector("[value=status_mode_not_break]").checked){

document.getElementById("status").innerHTML = ((score/20)/100).toFixed(2)+"<br>"+
typing_miss_count + "miss<span style='font-size:90%;color:"+life_corrent_color+";'>"+life_corrent+"</span><span style='display:block;line-height:0;margin-bottom:15.5px;font-size:95%;font-weight:normal;color:"+keep_corrent_color+";' ><span style='font-size:75%;'>正確率:</span><span style='font-size:85%;'>"+(correct.toFixed(1))+"%"+keep_corrent+"</span></span>"+
"<span style='margin-top:1.5px;'><span style='position:relative;top:-1.5px;'>"+combo+"</span><span style='position:relative;top:1.5px;font-size:80%;'>/"+max_combo+"<span style='font-size: 110%;'>combo</span></span></span><br>"+
"<span style='margin-top:1.5px;'><span style='position:relative;top:-1.5px;'>"+(total_notes-escape_word_length) + "</span><span style='position:relative;top:1.5px;font-size:80%;'>/" + total_notes + "</span><span style='position:relative;top:0.5px;font-size:105%;font-weight:normal;'>打</span></span><span style='font-size:80%;'>["+escape_word_length+"]esc<br></span>"+
"<span>"+(ranking_array.length +1) + "<span style='font-weight:normal;'>位</span></span><span>[<span id='type_speed'>"+typing_speed.toFixed(2)+"</span><span style='font-weight:normal;'>打/秒</span>]</span>";

}else{

if(document.querySelector("[value=perfect_mode]").checked&&document.querySelector("[value=life_corrent]").checked){
life_corrent ="<span class='status_text_result' style='margin-left: 3px;'>"+(total_notes-escape_word_length - (total_notes-escape_word_length) * document.querySelector("[name=miss_limit]").value/100-typing_miss_count).toFixed(1)+"<span style='color:"+localStorage.getItem('status_color')+"!important;'>/<span style='font-size:70%;'>"+typing_miss_count+"</span></span></span>"
}else{
life_corrent="<span class='status_text' style='margin-left: 3px;'>"+typing_miss_count+"</span>"
}

document.getElementById("status").innerHTML = "<div id=statu1dan style='box-pack: justify;    display: box;display: -webkit-box;display: -moz-box;display: -o-box;display: -ms-box;'>"+
"<div style='width:226px;'><span class='status_label'' style='font-size:75%;'> Score</span><span class='score_text' style='margin-left: 3px;'>"+((score/20)/100).toFixed(2)+"</span></div>"+
"<div style='width:137px;color:"+life_corrent_color+";'><span class='status_label' style='font-size:75%;'>"+miss_mode_life+"</span>"+life_corrent +"</div>"+
"<div style='width:168px;'><span class='status_label' style='font-size:75%;'>Combo</span><span class='score_text'style='margin-left: 3px;'>"+combo+"/<span style='font-size:70%;'>"+max_combo+"</span></span></div>"+
"<div style='display:block;width:226px;'><span class='status_label' style='font-size:75%;font-weight:normal;'>打/秒</span></span><span id='type_speed' class='status_text_result' style='margin-left: 3px;'>" +typing_speed.toFixed(2)+"/<span style='font-size:70%;'>"+Math.max.apply(null, kpmlog).toFixed(2)+"</span></span></div>"+
"<div style='display:block;visibility:hidden;'><span class='status_label' style='font-size:75%;'>Line</span><span class='line_text' style='margin-left: 3px;'>" +(line_length-(failer_count+complete_count))+"</span></div>"+
"</div><div id=statu2dan style='box-pack: justify;    display: box;display: -webkit-box;display: -moz-box;display: -o-box;display: -ms-box;margin-top:10px;'>"+
"<div style='width: 215px;display:block;'><span class='status_label' style='font-size:75%;'> Rank</span><span class='score_text2'style='margin-left: 7px;'>"+(ranking_array.length +1) + "<span style='font-weight:normal;'>位</span></span><span class='status_label' style='font-size:110%;position: relative;top:-11px;left: 42px;float:right;color:"+keep_corrent_color+";font-size:65%;font-weight:normal;'>"+keep_corrent+"</span></div>"+
"<div style='font-size:110%;width: 164px;color:"+keep_corrent_color+";'><span class='status_label' style='font-size:65%;font-weight:normal;'>正確率</span><span style='font-size:90%;margin-left: 3px;'class='status_text2'>"+(correct.toFixed(1))+"%</span></div>"+
"<div style='width:161px;'><span class='status_label' style='font-size:75%;'>Type</span><span class='status_text_result2'style='margin-left: 3px;'>"+(total_notes-escape_word_length) + "/<span style='font-size:70%;'>"+total_notes+"</span></span></div>"+
"<div style='display:block;width:212px;'><span class='status_label' style='font-size:75%;'>Esc</span><span class='status_text2'style='margin-left: 3px;'>"+escape_word_length + "</span></div>"+
"<div style='display:block;'><span class='status_label' style='font-size:75%;'>Clear</span><span class='status_text2'style='margin-left: 3px;'>"+complete_count + "/<span style='font-size:70%;'>"+line_length+"</span></span></div></div>";

}
}